Skip to content

Commit

Permalink
Add prepublishOnly script (#825)
Browse files Browse the repository at this point in the history
* Add prepublishOnly script

* Use normal function instead of arrow
  • Loading branch information
rubenmoya authored and developit committed Aug 24, 2017
1 parent 4ea1bc7 commit 5645573
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@
/dist
/_dev
/coverage
/.package.json

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

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

UNNECESSARY_KEYS.forEach(function (key) {
delete pkg[key];
});

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
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": "node ./config/donation-message.js"
Expand Down

0 comments on commit 5645573

Please sign in to comment.