execfile-subcommand
v1.0.1
Published
child_process#execFile with an additional `subcommand` argument
Maintainers
Readme
execfile-subcommand
child_process#execFile with an additional subcommand argument
const execFileSubcommand = require('execfile-subcommand');
execFileSubcommand('npm', 'view', ['[email protected]', 'version'], (err, stdout, stderr) => {
stdout; //=> '3.0.0\n'
});Installation
npm install execfile-subcommandAPI
execFileSubcommand(file, subcommand [, args, opts, cb])
file: String (filename of the program to run)
subcommand: String (subcommand of the root command)
args: Array of strings (arguments passed to the subcommand)
opts: Object (child_process#execFile options)
cb: Function (callback function)
Return: ChildProcess instance
Instead of running the root program directly as child_process#execFile does, it runs the given subcommand of the program specified with the second argument.
const execFileSubcommand = require('execfile-subcommand');
execFileSubcommand('npm' 'install', ['babel'], () => {/* ... */});
// --- is almost the same script as ---
const {execFile} = require('child_process');
execFile('npm' ['install', 'babel'], () => {/* ... */});License
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.
