Created
April 3, 2015 13:44
-
-
Save zoe-1/784100440f0cf2299010 to your computer and use it in GitHub Desktop.
Why use a Makefile with node.js project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start: | |
npm start | |
install: | |
npm install | |
test: | |
npm test | |
cov: | |
npm run test-coverage | |
cov-html: | |
npm run test-coverage-html | |
cov-mac: | |
npm run test-coverage-html | |
open -a Safari ./test/coverage.html |
If you use yarn
, then you will not need the extra run
like you do with npm. You could just run yarn protractor
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why use a Makfile
The Makefile is useful for automating tasks in your project.
npm commands can execute automated tasks but they can get very long. Long commands are inconvenient to type over and over.
For example, npm allows you to run two commands related to executing scripts by default: "npm start" and "npm test". If you make other custom npm commands in the scripts section, they will fail without "run" preceding the command.
ex) "npm run command_name" // illustrates a command with run before it.
The below command will list npm commands that do not need a "run" before them.
npm --help command // (Commands test and start are included here).
Look at: https://github.com/zoe-1/nmax/blob/master/package.json to see a package.json file with a significant amount of scripts commands in them. Commands are made in the scripts:{ } section.
In the above linked package.json file there is the below command:
"protractor": "protractor test/protractor-conf.js"
To execute this command you must type: "npm run protractor". "npm protractor" without will not work .
"npm run protractor" will run tests on the project. The command is a long. So, let's use a Makefile to
simplify the command.
Put in your Makefile:
Then type:
And, the long "npm run protractor" command will be executed.
As a project develops you will need automate tasks like:
In this assignment, I believe Eran is showing us how to use the Makefile as a convenient method
to manage and execute our projects most important automated tasks.