Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively copy files cross-platform via npm script

We have within a package.json build script a copy command (no we cant quickly change that).

Is there any solution we can make this work multiplatform with the same syntax easily?

I looked in several npm copy packages, but they don't transpile from windows to unix paths.

We basically need something like:

"build": "doStuff && cp -r ../folder/ /dist/"

working for windows.

Any ideas?

like image 944
fredalex Avatar asked Jan 20 '20 11:01

fredalex


1 Answers

For a cross-platform solution consider utilizing the shx package.

  1. Firstly cd to your project directory and run the following command to install it:

    npm i -D shx
    
  2. Then redefine your build script in the scripts section of your package.json as follows:

    "scripts": {
       "build": "doStuff && shx cp -r ../folder/ ./dist/"
    }
    
like image 140
RobC Avatar answered Oct 08 '22 23:10

RobC