1.0.9 • Published 8 years ago
wc-cmd v1.0.9
wc-cmd.js
execute cmd for windows on nodejs
Installation
npm install wc-cmd
Usage
It returns a promise, so you can use it like this to execute a cmd.
var cmd = require('wc-cmd')
cmd('mkdir hh').then(
function(data) {
console.log(process.cwd());
}
)
.then(
function() {
return cmd('dir')
}
)
.then(function(data) {
console.log(data.join(''))
console.log('all cmd over!')
})
And you can execute cmd queue in a array.
cmd(['rd hh', 'dir'])
.then(
function(data) {
console.log(data.join(''))
}
);
Using standard API
/**
* @param {string,array,object} command is a cmd command on windows.
* @param {function} callback The function will be called when command is over.
* @param {function,boolean} log=[function|true|false]
* @return {Promise}
* @example
* cmd('cd ../',null,console.log)
*/
cmd(command,callback,log)