Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
clean-scripts
Advanced tools
A CLI tool to make scripts in package.json clean.
npm i clean-scripts -g
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
module.exports = {
build: "tsc"
}
module.exports = {
build: [
"rimraf dist",
"tsc"
]
}
Set
or Object
scriptmodule.exports = {
build: {
js: `tsc`,
css: `cleancss -o index.bundle.css index.css`
}
}
module.exports = {
build: [
"rimraf dist",
{
js: `tsc`,
css: [
`lessc index.less > index.css`,
`cleancss -o index.bundle.css index.css`
]
}
]
}
the type of the function should be (context: { [key: string]: any }) => Promise<void>
module.exports = {
build: () => new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, 1000)
}),
test: async () => {
// todo
}
}
The context
can be used to transfer data between different scripts.
module.exports = {
build: [
context => {
context.foo = 'abc'
return Promise.resolve()
},
context => {
console.log(context.foo) // 'abc'
return Promise.resolve()
}
]
}
module.exports = {
build: [
`rimraf dist/`,
`tsc -p src/`
],
lint: {
ts: `tslint "src/**/*.ts"`,
js: `standard "**/*.config.js"`
}
}
clean-scripts build[0]
to run rimraf dist/
clean-scripts lint.ts
to run tslint "src/**/*.ts"
const { Service } = require('clean-scripts')
module.exports = {
build: [
new Service('http-server -p 8000'),
new Service('http-server', 'server2') // the child process can be accessed by `context.server2` later
]
}
All services will be killed after all scripts end, or any script errors.
const { sleep, readableStreamEnd } = require('clean-scripts')
module.exports = {
build: [
() => sleep(5000),
async () => {
const readable = getReadableStreamSomehow()
readable.on('data', chunk => {
console.log(`Received ${chunk.length} bytes of data.`)
})
await readableStreamEnd(readable)
}
]
}
FAQs
A CLI tool to make scripts in package.json clean.
The npm package clean-scripts receives a total of 9 weekly downloads. As such, clean-scripts popularity was classified as not popular.
We found that clean-scripts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.