execfile-subcommand

child_process#execFile with an additional `subcommand` argument

Usage no npm install needed!

<script type="module">
  import execfileSubcommand from 'https://cdn.skypack.dev/execfile-subcommand';
</script>

README

execfile-subcommand

NPM version Build Status Coverage Status devDependency Status

child_process#execFile with an additional subcommand argument

const execFileSubcommand = require('execfile-subcommand');

execFileSubcommand('npm', 'view', ['npm@3.0.0', 'version'], (err, stdout, stderr) => {
  stdout; //=> '3.0.0\n'
});

Installation

Use npm.

npm install execfile-subcommand

API

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.