Running bash scripts with npm

后端 未结 2 1102
挽巷
挽巷 2020-12-07 18:16

I want to try using npm to run my various build tasks for a web application. I know I can do this by adding a scripts field to my package.json lik

相关标签:
2条回答
  • 2020-12-07 18:46

    Its totally possible...

    "scripts": {
       "build": "./build.sh"
    },
    

    also, make sure you put a hash bang at the top of your bash file #!/usr/bin/env bash

    also make sure you have permissions to execute the file

    chmod +x ./build.sh
    

    Finally, the command to run build in npm would be

    npm run build
    
    0 讨论(0)
  • 2020-12-07 18:55

    Even Simpler:

    I routinely do this for one-offs and PoC's not involving a VCS

    package.json
    {
        "scripts": {
            "ship": "rsync -avz deployable/* <some-server>:/var/www/some-site/sub-dir/"
        },
    }
    ...
    
    0 讨论(0)
提交回复
热议问题