North Pittsburgh Meatpackers
    Wondering what’s next for npm?Check out our public roadmap! »

    @flemist/run-script
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.15 • Public • Published

    Build Status Test Coverage

    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,
    }

    See examples here

    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,
    }

    See the config example here

    License

    CC0-1.0

    Install

    npm i @flemist/run-script

    DownloadsWeekly Downloads

    60

    Version

    0.2.15

    License

    CC0-1.0

    Unpacked Size

    332 kB

    Total Files

    56

    Last publish

    Collaborators

    • avatar