Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ndraiman/b8d848234887bcb79a7a69211f41c42b to your computer and use it in GitHub Desktop.
Save ndraiman/b8d848234887bcb79a7a69211f41c42b to your computer and use it in GitHub Desktop.
Scripts to streamline/enforce the copy and publish subdir method (https://stackoverflow.com/a/39946795/2234013). idk if copying package.json is necessary
{
"prepublishOnly": "if [[ ! $PWD =~ dist$ ]]; then npm run _dist:nopublish; fi",
"_dist:nopublish": "echo 'Use `npm run dist` instead of `npm publish`!' && exit 1",
"_dist:prep": "yarn build && cp package.json dist && cp README.md dist",
"_dist:post": "rm -f dist/package.json && rm -f dist/README.md",
"dist": "npm run _dist:prep && npm publish dist && npm run _dist:post"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment