1

I have a simple command I would like to use in my NPM scripts. The command is:

cat ./path/**/*.css > ./other/path/plugins.css

If I run this in my terminal, it works. If however I put it in an NPM script, like so:

"scripts" {
     "cat": "cat ./path/**/*.css > ./other/path/plugins.css"
}

I will get No such file or directory.

Any idea what might be the reason?

Thanks!

1 Answer 1

1

The reason it does not work is because cat accepts filenames as parameters and the asterisks (glob) is converted to the filenames by your shell (most probably, bash).

The reason it doesn't work with npm script is because it is not being run in the shell which supports the features you want to use (glob expansion, stdout redirect to file).

To solve it, just run it in an instance of bash:

"scripts" {
     "cat": "bash -c 'cat ./path/**/*.css > ./other/path/plugins.css'"
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.