NPM script - Run command for each file in a folder / glob

Viewed 134

Is it possible to create a NPM script that runs a command for a glob ?

Specifically, in my case, I want to run a command for each file in a folder.

For example, I want to run this command for every file in my assets folder:

gltf-pipeline -i model.gltf -o modelDraco.glb -d

My assets folder contains a car.gltf and plane.gltf files. The project would be something like the following:

  • assets
    • car.gltf
    • plane.gltf
  • package.json

How would I go by executing that command for each file in a NPM script ?

I know how to do it as a Python script but it would be much easier if it could be done inside of NPM directly.

0 Answers
Related