Wednesday, 12 April 2017

How to load an external file inside npm script?

I am trying to execute a command on all the folders inside a config file :

"lint1": "eslint src/actions"
"lint2": "eslint src/components/component1"
"lint3": "eslint src/components/component2"
....

Instead of having multiple commands for each folder, I want my npm script to load all the required folder paths from an external config file(something like below) and iteratively run the lint for each of those paths in one command.

//config.js
paths = [
'src/actions',
'src/components/component1',
'src/components/component2',
'src/components/component3',
]

How to do this ? or any better way to do it using npm?

PS: I dont want to do it the other way around by putting the unwanted paths in eslintignore.js file



via Sahil Sharma

No comments:

Post a Comment