Skip to content
Nate Fischer edited this page Jul 24, 2018 · 3 revisions

This doesn't work with electron!

Please see our list of known issues with Electron. If your issue is not on the list, feel free to file a Github issue.

How can I execute local binaries? (i.e. installed under node_modules/.bin/)

You should be able to do this easily with just one extra line:

// foo.js
process.env.PATH += (path.delimiter + path.join(__dirname, 'node_modules', '.bin'));
shell.exec('ava --serial test.js');

If your script lives somewhere else, you can change the PATH as appropriate:

// scripts/foo.js
process.env.PATH += (path.delimiter + path.join(__dirname, '..', 'node_modules', '.bin')); // make sure to include '..'

If you need to override globally-installed binaries (perhaps you need to make sure it's your exact same ava), you can prepend to the PATH:

// foo.js
process.env.PATH = (path.join(__dirname, 'node_modules', '.bin') + path.delimiter) + process.env.PATH;

Running interactive programs with exec()

We don't currently support running commands in exec which require interactive input. The correct workaround is to use the native child_process module:

child_process.execFileSync(commandName, [arg1, arg2, ...], {stdio: 'inherit'});

Using npm init as an example:

child_process.execFileSync('npm', ['init'], {stdio: 'inherit'});