Skip to content

Instantly share code, notes, and snippets.

@sjparkinson sjparkinson/Makefile
Last active Aug 30, 2018

Embed
What would you like to do?
# To build the application run `make install`.
#
# This target depends on the `node_modules` target.
install: node_modules
# This target depends on a file called `package.json`.
#
# If `package.json` doesn't exist, make complains that you need one! Run `npm init` to generate one.
#
# If `package.json` exists, but `node_modules/` doesn't, make will run `npm install`.
#
# If `package.json` and `node_modules/` exist, make will compare the last time they were both modified.
#
# Then if `package.json` has been modified more recently than `node_modules/`, and because `package.json` is a dependency of `node_modules/` make knows there have been changes and should run `npm install`.
#
# When the modified time of `package.json` and `node_modules/` are the same (or `node_modules/` is more recent), make knows that `node_modules/` is up to date and doesn't need to run `npm install`.
#
# Try running `npm init`, `make install`, and `npm install <some-package>` in diffrent orders and see when `npm install` is run or not.
#
# You can see last modified times to files and folders using `stat <path>`.
#
# The `touch` command will update the last modified time of a file or folder, so see what `touch package.json` and then `make install` does too.
node_modules: package.json
npm install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.