Is it possible to include a for loop inside a package.json file to recurse into subdirectories and execute a command in each:
# .env File
DIRECTORIES="Dir1, Dir2"
# package.json file in parent directory
"scripts": {
"install-all-inefficient": "(cd ./dir/Dir1/ && npm install) && (cd ./dir/Dir2/ && npm install)",
"install-all-ideal": ". .env && functionToLoopThroughDirectoriesDefinedInEnvironmentVariables",
},
I was looking at this: Defining an array as an environment variable in node.js as an example for defining the array, and then trying to somehow use process.env.DIRECTORIES
to create a loop without writing too much ugly bash script.