Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prepublishOnly script #825

Merged
merged 3 commits into from
Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/dist
/_dev
/coverage
/.package.json

# Additional bundles
/devtools.js
Expand Down
20 changes: 20 additions & 0 deletions config/prepublish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require('path').join(__dirname, '..', 'package.json');
const pkg = require(path);

const UNNECESSARY_KEYS = [
'babel',
'greenkeeper',
'bundlesize',
'devDependencies',
'eslintConfig'
];

UNNECESSARY_KEYS.forEach(key => delete pkg[key]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably best to keep this as a normal function to support Node 6


pkg.scripts = {
donate: pkg.scripts.donate,
postinstall: pkg.scripts.postinstall,
postpublish: 'mv -f .package.json package.json'
};

require('fs').writeFileSync(path, JSON.stringify(pkg, null, 2));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"test:size": "bundlesize",
"lint": "eslint debug devtools src test",
"prepublish": "npm run build",
"prepublishOnly": "cp package.json .package.json; node config/prepublish.js",
"smart-release": "npm run build && npm test && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish",
"release": "cross-env npm run smart-release",
"postinstall": "npm run -s donate",
Expand Down