question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow cli to be executed against arbitrary package.json scripts?

See original GitHub issue

Let’s say I have package.json scripts declaration like this:

"scripts": {
  "stats": "webpack --profile --json > stats.json",
  "start": "webpack-dev-server",
  "deploy": "gh-pages -d build",
  "build": "webpack",
  "test": "karma start",
  "test:tdd": "karma start --auto-watch --no-single-run",
  "test:lint": "eslint . --ext .js --ext .jsx --ignore-path .gitignore --ignore-pattern dist --cache"
},

I would like to run webpack-validator cli against all of these (separate script) without having to spell each script explicitly.

My current tooling figures out which webpack configuration to run based on process.env.npm_lifecycle_event. I would need some neat way to run the validator while setting that against each script name.

How would you solve this? I could probably handle it outside of webpack-validator but some kind of integration might be cool as well. Then you would perhaps point the validator to package.json and it would just work.

If we can agree on a specification, I could implement it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bebrawcommented, May 9, 2016

--all-scripts would be cool, yeah.

The implementation takes a couple of further tweaks (need to do path.join against process.cwd() etc.) but I don’t mind doing a PR.

0reactions
jonathanglasmeyercommented, May 9, 2016

Ok, now I understand it much better. Well, it’ll probably be really handy for 80 percent of people’s setups. As long as we have an explicit description what it can and can’t do in the README, I think we can put it on the cli, maybe with --all-scripts, --from-scripts or --scripts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm-exec
This command allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar...
Read more >
pass cli args anywhere into an npm run scripts command with ...
ok, i found a solution. I can wrap whatever i need to pass into an npm script command into a cli tool, that...
Read more >
Preventing npm from Executing Arbitrary Scripts - NerdyCode
In 2016, npm disclosed the discovery of a vulnerability that essentially allows npm packages to execute potentially malicious code on your ...
Read more >
Why doesn't "npm run" run my arbitrary package script?
Also, make sure ignore-scripts is not set to true globally. npm config set ignore-scripts false.
Read more >
Using NPM Run-Scripts To Execute Shell Commands In ...
As it turns out, there is a --prefix argument which will force the npm CLI tool to execute the subsequent commands from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found