2

I am working on an angular js project and I would like to automate The following two commands.

./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager start

The issue is that I am working on a small angular project on github. I added all dependencies required to my package.json, However when my friend pulled it from git he was able to install protractor but he could not get webdriver to start unless he ran the above two commands. So i wanted to write some script to automate it and better yet even add protractor ./conf.js to it.

So I did research and I am aware that I can write a npm script but I was not able to find a proper document that showed where to write the script and how to execute it. I would appreciate all suggestions.

2 Answers 2

4

You can add a scripts property to your package.json with the command you wish you run.

"scripts": {
  "prostart": "./node_modules/protractor/bin/webdriver-manager start",
  "proupdate": "./node_modules/protractor/bin/webdriver-manager update"
}

you would then run these by typing npm run prostart or npm run proupdate which would look for those commands in your package.json.

Sign up to request clarification or add additional context in comments.

7 Comments

Would you run it using npm like "npm update" and "npm start" ??
npm update will update all dependencies I think so maybe it is better to use another word instead.
Agreed. I would name them more appropriately. Additionally you can use && to concatenate the two commands if they are always run together in a particular order.
so something like this ./node_modules/protractor/bin/webdriver-manager update && ./node_modules/protractor/bin/webdriver-manager start ?
Yes that is it, @Dinero. Although, as you mention start/update should probably be renamed to something more specific.
|
1

In addition to Josh's answer, the script start could be run as npm start as start is a special keyword, but update should be run as npm run update because npm update is another npm command entirely.

For any other command besides start and test (I think), you have to preface it with npm run ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.