@flemist/run-script
v2.1.18
Published
Use JavaScript instead npm scripts
Downloads
84
Maintainers
Readme
Description
Run
run-script "console.log(123)"
run-script --config .run-script-rc.js "console.log(123)"
run-script "require(./scripts.js).run({ option1: true, option2: true })"
Script helpers
const {run, singleCall, singleProcess} = require('../helpers/helpers')
// singleCall - Create function that skip all executions except first
const buildMjs = singleCall(() => {
// run - execute command line
const {out, err, both} = await run(`babel src -x .js -x .ts`, {
// see: IRunOptions
returnOutputs: true,
})
})
// singleProcess - Create function that wait unlit previous execution is completed before the next one
const build = singleProcess(async appConfigType => {
await Promise.all([
common.build(),
buildMjs(appConfigType),
buildJs(appConfigType),
])
})
export interface IRunOptions {
env?: ProcessEnv,
cwd? : string,
timeout?: number,
notAutoKill?: boolean, // don't auto kill all process tree after error
stdin?: undefined | null | 'pipe' | 'ipc' | 'ignore' | 'inherit' | Stream,
shell?: boolean,
prepareProcess?: (proc: ChildProcess) => void,
dontSearchErrors?: boolean,
dontShowOutputs?: boolean,
returnOutputs?: boolean,
}
Config
Default config path is ./.run-script-rc.js
Config type:
type TextPredicate = (text: string, next: TextPredicate) => boolean
type ErrorSearch = (text: string, next: ErrorSearch) => string | void | null | false
type IGlobalConfig = {
logFilter?: TextPredicate,
stdOutSearchError?: ErrorSearch,
stdErrIsError?: TextPredicate,
}