[Fixed] How to pass a script argument with run-s to a pre-script task in Node?

Issue

I am trying to run a script before the build script in a multi module Angular project. The script copies some files so I thought I’d put it in the prebuild script. But it seems that this won’t get passed at all:

{
    "scripts": {
        "prebuild": "node ./copyscript.js",
        "build": "ng build"
    }
}

I thought It’d be possible with run-s but I am not able to get it to work.

{
    "scripts": {
        "build": "run-s \"copy\ -- {1}" && ng build"
    }
}

I run the scripts via: npm run build proj1.

My attempts so far have failed. Is there any way to achieve this?

Solution

I finally found a way:

{
    "scripts": {
        "build": "run-s \"build:copy {1}\" \"build:run {@}\" --",
        "build:copy": "node ./copyscript.js",
        "build:run": "ng build"
    }
}

Leave a Reply

(*) Required, Your email will not be published