npm-scripts

NPM run parallel task, but wait until resource is available to run second task

安稳与你 提交于 2019-12-03 13:07:41
In npm, how can I run two or more parallel tasks, but waiting for the resource that the first task will create to be available to the second task to use it, and so forth? example (conceptual): npm run task1 & waitfor task1 then task2 & waitFor task3 then task4 ... any ideas? EDIT As an example: Lets say that my first task is starting a webserver, and my second task is consuming data from that web-server every time an event happens. Another example: My first task could be starting webdriver-manager, my second task, starting a webserver, and my third task, run e2e tests everty time my files are

How to open browser to localhost through npm scripts

假如想象 提交于 2019-12-03 05:00:16
I've been trying to figure out how to write a npm script that will culminate with the application being launched in the user's browser without them having to manually open the browser and go to localhost:1234 . Right now my script reads as: "start": "npm run build && npm run dev", "build": "npm run clean && npm run mkdir && npm run build:html && npm run build:css && npm run build:js", "dev": "webpack-dev-server --inline --hot --content-base build --history-api-fallback", Wanting to add "open": <some code here>, So when someone goes to GitHub and clones or forks off my repository they are given

How to handle script dependencies in angular 2 module published to npm

五迷三道 提交于 2019-12-02 18:03:29
问题 I have published an angular 2 library to npm recently.I have listed all the dependency scripts in the libraries package.json file. when I run npm install my-library all the dependency scripts are not installed.So, my question is how to install the dependency scripts while installing the library. 来源: https://stackoverflow.com/questions/47289167/how-to-handle-script-dependencies-in-angular-2-module-published-to-npm

How can I reference package version in npm script?

冷暖自知 提交于 2019-12-02 17:34:22
I want to reference my package version in a npm script so I can show current version in the app. Something like { "name": "bla", "version": "1.0.0", "author": "bla bla", "scripts": { "build": "node VERSION=<<package.version>> build/build.js" } } Is there a way to do this? 1) Referencing package version in npm-scripts. In npm-script 's you can reference the version using the variable npm_package_version . For example: Using a bash shell (E.g. Linux, macOS): { ... "version": "1.0.0", "scripts": { "build": "echo $npm_package_version" } } Note the $ prefix Using Windows (E.g. cmd.exe, Powershell):

How to use Windows console 'set' variables with NPM scripts?

…衆ロ難τιáo~ 提交于 2019-12-02 14:13:31
问题 This works in Windows console as expected: set A="qwerty" && echo %A% the output: "qwerty" But when I try to run the same commands in NPM scipts: package.json: "scripts": { "qwerty": "set A=\"qwerty\" && echo %A%" } > npm run qwerty the output is: %A% Am I doing something wrong or it just shouldn't work that way when run by NPM? 回答1: Your example set A="qwerty" && echo %A% isn't correct. Variables in the cmd prompt / a batch file are expanded once per line / command: ==> set "A=" ==> echo %A%

How to handle script dependencies in angular 2 module published to npm

混江龙づ霸主 提交于 2019-12-02 09:02:25
I have published an angular 2 library to npm recently.I have listed all the dependency scripts in the libraries package.json file. when I run npm install my-library all the dependency scripts are not installed.So, my question is how to install the dependency scripts while installing the library. 来源: https://stackoverflow.com/questions/47289167/how-to-handle-script-dependencies-in-angular-2-module-published-to-npm

Cross-platform way to pass environment variables as arguments to npm scripts

我的未来我决定 提交于 2019-12-02 05:08:30
问题 From both Windows or Linux, I want a way to pass args to a npm script , but have them be injected as environment variables From the command line, I'd start my project in this fashion: npm run start -- --env=dev --host=localhost --port=1234 To consume my cli args & inject them as env variables regardless of platform, I used the cross-env npm package : package.json "scripts": { "start": "cross-env env=%env% host=%host% port=%port% my-app" }, I understand the above is invalid syntax, but can

Pass argument from script to gulp task

独自空忆成欢 提交于 2019-12-02 04:06:34
I have package.json scripts with the following structure: "scripts": { "watch:build": "tsc --watch", "watch:server": "nodemon ./src/app.js --watch 'app'", "build": "tsc && gulp do_something", "start": "npm-run-all clean build --parallel watch:build", "watch:server --print-label" } I would like to start the application as npm run start with_argument and pass it to build script, to perform actions in the gulp task based on that argument. I read a lot of tutorial and how to articles, but without result. It is possible somehow to pass argument from one script to another(which starts a gulp task).

How to use Windows console 'set' variables with NPM scripts?

自作多情 提交于 2019-12-02 03:13:38
This works in Windows console as expected: set A="qwerty" && echo %A% the output: "qwerty" But when I try to run the same commands in NPM scipts: package.json: "scripts": { "qwerty": "set A=\"qwerty\" && echo %A%" } > npm run qwerty the output is: %A% Am I doing something wrong or it just shouldn't work that way when run by NPM? Your example set A="qwerty" && echo %A% isn't correct. Variables in the cmd prompt / a batch file are expanded once per line / command: ==> set "A=" ==> echo %A% %A% ==> set A="qwerty" && echo %A% %A% ==> echo %A% "qwerty" Why this behaviour? The SET command was first

How to pass a command line argument to a nested script?

a 夏天 提交于 2019-11-29 08:37:56
NOTE: This is NOT about sending args to the top-level script, but to the script called by that script In my package.json, when I call a script that takes command line args directly, it works. But when I call a script that calls that other script, it's not passing the command line args to it. How do i pass them? { ... "takes-args": "somemodule", "calls-takes-args": "npm run takes-args" } When i run the below command, the args come through: npm run takes-args -- -env dev But when I run it through the other script, it never gets the args. Is there some way to pass them down? Maybe by a variable