Execute shell, bash command or file asynchronously from Node.js scripts and get user-definable type of output.
npm install --save-dev njshell
exec(cmd, type, filename, encoding):
cmd
Command String (required)
type
Type of output: stdout(default), string, buffer, stream, vinyl.
filename
Only required when type of output is "vinyl".
encoding
Default utf-8.
execLocal(cmd, type, filename, encoding):
Same as "exec" but uses npm package's local path "node_modules/.bin/..." as of executable directory.
const shell = require('njshell');
shell.exec('npm view njshell version')
.then((v) => console.log(v));
// outputs 1.2.4...
shell.exec('dir')
.then((dir) => console.log(dir));
/*
outputs...
Directory of D:\projects\njshell
17.10.2020 16:03 <DIR> .
17.10.2020 16:03 <DIR> ..
15.10.2020 12:15 279 .editorconfig
15.10.2020 12:15 748 .eslintrc.js
15.10.2020 12:15 51 .gitignore
15.10.2020 12:15 29 .npmignore
15.10.2020 12:15 47 .travis.yml...
*/
When you encounter a problem, please open an issue. I would be glad to help you to find a solution if possible.
Github: @orcunsaltik
See the LICENSE file for license rights and limitations (MIT).