njshell

1.1.2 • Public • Published

Node Js Shell

Build Status devDependencies Status Maintainability Snyk Vulnerabilities for GitHub Repo npm NPM Version contributions welcome node-current

Execute shell, bash command or file asynchronously from Node.js scripts and get user-definable type of output.

Install

npm install --save-dev njshell

Methods

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.

Usage

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...
*/

Troubleshooting

When you encounter a problem, please open an issue. I would be glad to help you to find a solution if possible.

Author

Github: @orcunsaltik

License

See the LICENSE file for license rights and limitations (MIT).

Package Sidebar

Install

npm i njshell

Weekly Downloads

3

Version

1.1.2

License

MIT

Unpacked Size

7.2 kB

Total Files

5

Last publish

Collaborators

  • orcunsaltik