clean-scripts
A CLI tool to make scripts in package.json clean.
install
npm i clean-scripts -g
usage
create config file(named clean-scripts.config.js
or something else) like:
module.exports = {
build: "tsc",
lint: "tslint index.ts"
}
run clean-scripts build
, or clean-scripts lint
or clean-scripts build --config clean-scripts.config.js
features
string script
module.exports = {
build: "tsc"
}
array script
- executed one by one with order
- used when later script depends on previous script's success
module.exports = {
build: [
"rimraf dist",
"tsc"
]
}
Set
or Object
script
- executed collaterally without order
- used when the scripts are irrelated
- they are all started at first time, when they are all done, it's a success, otherwise exit current process
module.exports = {
build: {
js: `tsc`,
css: `cleancss -o index.bundle.css index.css`
}
}
nested script
module.exports = {
build: [
"rimraf dist",
{
js: `tsc`,
css: [
`lessc index.less > index.css`,
`cleancss -o index.bundle.css index.css`
]
}
]
}
Promise
script
module.exports = {
build: () => new Promise((resolve, reject) => {
setTimeout(() => {
resolve('abc')
}, 1000)
})
}
child script
module.exports = {
build: [
`rimraf dist/`,
`tsc -p src/`
],
lint: {
ts: `tslint "src/**/*.ts"`,
js: `standard "**/*.config.js"`
}
}
- run
clean-scripts build[0]
to run rimraf dist/
- run
clean-scripts lint.ts
to run tslint "src/**/*.ts"