Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a sub-folder in package.json

In my package.json (from npm), I have the following build command:

"build": "mkdir -p ./build && cp ./src/index.html ./build/ && webpack -p --config webpack.production.config.js"

This command runs just fine and creates a "build" folder with almost everything I need.

However, I also need to make the build command create a sub-directory (in the build folder) called "images" .

I tried a few things, such as the following:

 "build": "mkdir build && mkdir -p ./build/images && cp src/index.html build/ && webpack -p --config webpack.production.config.js"

And it always returns this error

How can I change this build command to create a sub-directory inside the build folder?

like image 378
Edon Avatar asked Feb 07 '23 10:02

Edon


1 Answers

This is because of the sub-POSIX-standard Windows mkdir command. Writing portable shell commands this way is difficult and limiting.

One option would be to install and use the mkdirp module. Then a pure and portable JavaScript mkdirp command will be available to the npm scripts.

npm install --save-dev mkdirp

Command:

"build": "mkdirp ./build && mkdirp ./build/images && ..."
like image 54
Alexander O'Mara Avatar answered Feb 08 '23 22:02

Alexander O'Mara