Skip to content

Instantly share code, notes, and snippets.

@DaneTheory
Last active June 24, 2021 15:53
Show Gist options
  • Select an option

  • Save DaneTheory/f6db31f92813bfc5b35f3a14a8a134af to your computer and use it in GitHub Desktop.

Select an option

Save DaneTheory/f6db31f92813bfc5b35f3a14a8a134af to your computer and use it in GitHub Desktop.
The Package (dot) JSON: A story of love, triumph, and general witchcraft/wizardry - InitFields: Scripts
[{
"npm:current": {
"ref": "",
"source": [
]
},
"npm:legacy": {
"ref": "",
"source": [
]
},
"yarn:current": {
"ref": "https://yarnpkg.com/configuration/manifest#scripts",
"source": [
"A field used to list small shell scripts that will be executed when running 'yarn run'. Scripts are by default executed by a miniature shell, so some advanced features might not be available (if you have more complex needs, we recommend you to just execute a Javascript file). Note that scripts containing : (the colon character) are globals to your project and can be called regardless of your current workspace. Finally, be aware that scripts are always executed relative to the closest workspace (never the cwd).",
"_example_:{ \n \"scripts\": \n { \n \"test\": \"jest\", \n \"build\": \"webpack-cli --config ./webpack.config.js\", \n \"count-words\": \"echo \"$@\" | wc -w\" \n } \n }:_example_"
]
},
"yarn:legacy": {
"ref": "https://classic.yarnpkg.com/en/docs/package-json/#toc-scripts",
"source": [
"Scripts are a great way of automating tasks related to your package, such as simple build processes or development tools. Using the \"'scripts'\" field, you can define various scripts to be run as 'yarn run <script>'. For example, the 'build-project' script above can be invoked with 'yarn run build-project' and will run 'node build-project.js'.",
"Certain script names are special. If defined, the 'preinstall' script is called by yarn before your package is installed. For compatibility reasons, scripts called 'install', 'postinstall', 'prepublish', and 'prepare' will all be called after your package has finished installing.",
"The 'start' script value defaults to 'node server.js'.",
"_example_:{ \n \"scripts\": { \n \"build-project\": \"node build-project.js\"} \n } \n }:_example_"
]
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment