build: use npm prepare instead of prepublishOnly #1533
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In NPM, the
prepublishOnly
script is run only before runningnpm publish
. However, this means that people trying to use the git version of of this project (i.e. withnpm install github:ferdikoomen/openapi-typescript-codegen
) won't get a working version of this project, since there will be nothing in thedist/
folder.NPM (since v4.0.0) supports a
prepack
script, that is called:According to the NPM docs, this is the recommended place to put scripts that do things like "Compiling CoffeeScript source code into JavaScript.".
Fixes #1457, resolves #1458 (this PR is cleaner than that PR)
Benefits
Installing directly from
git
can be pretty useful, as it allowsopenapi-typescript-codegen
users to use a specific git commit/branch, e.g. so that they don't need to wait for an NPM release (or people can use a commit from a PR that hasn't yet been merged).Tests
Testing:
npx github:ferdikoomen/openapi-typescript-codegen --help
(fails)npx github:aloisklink/openapi-typescript-codegen#build/use-npm-prepare-instead-of-prepublishOnly --help
(works)npm publish
: