0.1.4 • Published 9 years ago
reliable-shell v0.1.4
reliable-shell
build shell helper
Requirement
node version >= v5
Install
npm install reliable-shellUsage
cmd
add command with options
const sh = require('reliable-shell');
sh.cmd('npm -v');
// or with options
sh.cmd('npm -v', [
'timing', // echo running duration time
'assert', // assert result ($?)
'echo', // echo cmmand name
'no-fold' // without fold
])raw
just command, without options
sh.raw('npm -v');echo
shell command echo alias
sh.echo('npm -v'); // echo "npm -v"export
shell command export alias
sh.export('KEY', 'VALUE'); // export KEY=VALUEif
sh.if('-f package.json', () => {
sh.raw('npm -v');
});
// if [[ -f packages.json ]]; then
// npm -v
// fielse
add else after if
elif
sh.elif('-f makefile'); // elif [[ if makefile ]]; thenfor
need 3 or 4 arguments
sh.for('i=0', 'i<10', 'i++', () => {
sh.raw('npm -v');
});
// for(( i=0; i<10; i++ )); do
// npm -v
// done
sh.for('item', '$(ls)', () => {
sh.echo('$item');
})
// for item in $(ls); do
// echo "$item"
// doneLICENSE
MIT