0.0.0 • Published 6 years ago
shelit v0.0.0
SHELIT
A small node.js tool to run shell commands
Importing the Library
// using es2015
import { run, runParallel, runSeries } from 'shelit'
// or using commonjs
const shelit = require('shelit')
Usage
shelit.run Run a single shell command
// Promises
shelit.run("rm -rf node_modules").then(() => {
console.log("command finished");
}).catch(err => {
console.log("oops! error happened", err)
})
// async await
async function removeModules() {
try {
await shelit.run("rm -rf node_modules")
} catch(err) {
console.log("oops! error happened", err)
}
}
shelit.runSeries Run multiple commands in series
// async await
async function removeModules() {
let commands = [
"rm -rf node_modules",
"npm i"
];
try {
await shelit.runSeries(commands)
} catch(err) {
console.log("oops! error happened", err)
}
}
shelit.runParallel Run multiple commands in parallel
// async await
async function removeModules() {
let commands = [
"rm -rf node_modules",
"rm -rf dist"
];
try {
await shelit.runParallel(commands)
} catch(err) {
console.log("oops! error happened", err)
}
}
0.0.0
6 years ago