Skip to content

Commit

Permalink
fix(build): fix postinstall to check if files exist
Browse files Browse the repository at this point in the history
The postinstall hook runs when this package is installed by other packages as well, causing npm
install to fail since the postinstall hook where dependent on local files in this package
  • Loading branch information
jgroth authored and adrianschmidt committed Sep 10, 2019
1 parent c7cb45e commit a44c621
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"dist/"
],
"scripts": {
"postinstall": "npm run install-flatpickr && npm run rm-jsx-dom-types",
"install-flatpickr": "cp ./src/dev-assets/hack/flatpickr.js ./node_modules/flatpickr/dist/flatpickr.js",
"rm-jsx-dom-types": "node remove-jsx-dom-types.js",
"postinstall": "node postinstall.js",
"build": "cross-env-shell NODE_ENV=prod SASS_PATH=node_modules \"stencil build --config stencil.config.dist.ts\"",
"cm": "git-cz",
"dev": "cross-env-shell SASS_PATH=node_modules \"stencil build --dev --docs\"",
Expand Down
22 changes: 22 additions & 0 deletions postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');

// Copy pre-built version of flatpickr
// TODO: remove this when a new version of flatpickr has been released
fs.exists('src/dev-assets/hack/flatpickr.js', () => {
fs.copyFile(
'src/dev-assets/hack/flatpickr.js',
'node_modules/flatpickr/dist/flatpickr.js',
() => {
console.log(
'copied src/dev-assets/hack/flatpickr.js to node_modules'
);
}
);
});

// Remove type definitions for jsx-dom
fs.exists('node_modules/jsx-dom/jsx-dom.d.ts', () => {
fs.unlink('node_modules/jsx-dom/jsx-dom.d.ts', () => {
console.log('jsx-dom.d.ts removed!');
});
});
4 changes: 0 additions & 4 deletions remove-jsx-dom-types.js

This file was deleted.

0 comments on commit a44c621

Please sign in to comment.