MacOs react-native-childprocess know the pwd

61 views Asked by At

I tried running the following command on macos for react-native-macos.

But it's not working properly.

Can you give me a hand?

the first time it was worth:

 console.log('o:', cmdID);

then changed it by saving it, then it updated:

  console.log('oo:', cmdID);
import { spawn, kill } from 'react-native-childprocess';


useEffect(() => {
    let cmdID;
    const shell = async () => {
      cmdID = await spawn('pwd', ['-LP'], {
        pwd: '/Users',
        stdout: (output) => {
          console.log('stdout:', output);
        },
        stderr: (output) => {
          console.log('stderr:', output);
        },
        terminate: (output) => {
          console.log('terminate:', output);
        },
      });
      console.log('oo:', cmdID);
    };

    shell().catch(console.error);
    return () => {
      console.log("kill")
      kill(cmdID);
    };
  }, []);
 LOG  o: -1
 LOG  kill
 LOG  [Error: invalid cmdID]
 LOG  oo: -1
0

There are 0 answers