Created
January 9, 2018 21:18
-
-
Save thomd/031d94c2cabc479507a8d07dafe79d46 to your computer and use it in GitHub Desktop.
Test lifecycle of npm scripts
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # npm help 7 npm-scripts | |
| scripts=(prepublish prepare prepublishOnly prepack postpack publish postpublish preinstall install postinstall | |
| preuninstall uninstall postuninstall preversion version postversion pretest test posttest prestop stop | |
| poststop prestart start poststart prerestart restart postrestart preshrinkwrap shrinkwrap postshrinkwrap) | |
| n=${#scripts[@]} | |
| cat <<EOF > package.json | |
| { | |
| "name": "npm-scripts-lifetime", | |
| "version": "1.0.0", | |
| "description": "Check which system npm scripts are running", | |
| "scripts": { | |
| EOF | |
| for script in ${scripts[@]:0:$[$n-1]} | |
| do | |
| echo " \"$script\": \"echo $script\"," >> package.json | |
| done | |
| last=${scripts[$[$n-1]]} | |
| echo " \"$last\": \"echo $last\"" >> package.json | |
| cat <<EOF >> package.json | |
| } | |
| } | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment