Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcut for running npm scripts #31

Open
keithamus opened this issue Sep 2, 2015 · 2 comments
Open

Shortcut for running npm scripts #31

keithamus opened this issue Sep 2, 2015 · 2 comments

Comments

@keithamus
Copy link
Collaborator

It'd be nice if parallelshell has a shortcut for running npm scripts, something like:

parallelshell 'npm run build' # old style
parallelshell -n 'build' # shorthand style

We could also use globbing here, to expand multiple npm scripts; for example:

parallelshell 'npm run build:js' 'npm run build:css' 'npm run build:html' # old style
parallelshell -n 'build:js' -n 'build:css' -n 'build:html'  # new shorthand style
parallelshell -n 'build:*' # new shorthand style with globs

Of course, each string would have the -n flag so they could be mixed and matched:

parallelshell 'npm run build:js' 'echo normal command' 'npm run build:html' # old style
parallelshell -n 'build:js' 'echo normal command' -n 'build:html' # new shorthand style
@paulpflug
Copy link
Collaborator

I like it
Argument parsing would need a rewrite and we would need something to
translate the globbing.. Npm has no API for it, does it? So simple
project.json grep?

Am 3. September 2015 12:34:01 vorm. schrieb Keith Cirkel
notifications@github.com:

It'd be nice if parallelshell has a shortcut for running npm scripts,
something like:

parallelshell 'npm run build' # old style
parallelshell -n 'build' # shorthand style

We could also use globbing here, to expand multiple npm scripts; for example:

parallelshell 'npm run build:js' 'npm run build:css' 'npm run build:html' # 
old style
parallelshell -n 'build:*' # new shorthand style

Reply to this email directly or view it on GitHub:
#31

@keithamus
Copy link
Collaborator Author

Grepping the project.json would be the most straightforward. I think we only (realistically) need to support foo* or *foo - in other words a search by prefixes or suffixes. We could trivially implement this by parsing the package.json in the cwd, calculating if the glob is a prefix or suffix glob, iterating over keys and match using indexOf().

For argument parsing, I'd recommend we use minimist, as it is trivial to use and can pass multiple flags as an array of values, e.g.:

node -p 'require("minimist")(process.argv.slice(1));' -- 'foo' 'bar' -n 'foo' -n 'bar'
{ _: [ 'foo', 'bar' ], n: [ 'foo', 'bar' ] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants