From a44c6215c77c150c7a57a74ebb8735421bc53617 Mon Sep 17 00:00:00 2001 From: Johan Groth Date: Tue, 18 Dec 2018 15:28:33 +0100 Subject: [PATCH] fix(build): fix postinstall to check if files exist 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 --- package.json | 4 +--- postinstall.js | 22 ++++++++++++++++++++++ remove-jsx-dom-types.js | 4 ---- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 postinstall.js delete mode 100644 remove-jsx-dom-types.js diff --git a/package.json b/package.json index 8556064999..c488691987 100644 --- a/package.json +++ b/package.json @@ -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\"", diff --git a/postinstall.js b/postinstall.js new file mode 100644 index 0000000000..9bb0f7698b --- /dev/null +++ b/postinstall.js @@ -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!'); + }); +}); diff --git a/remove-jsx-dom-types.js b/remove-jsx-dom-types.js deleted file mode 100644 index e1e094db0f..0000000000 --- a/remove-jsx-dom-types.js +++ /dev/null @@ -1,4 +0,0 @@ -const fs = require('fs'); -fs.unlink('node_modules/jsx-dom/jsx-dom.d.ts', () => { - console.log('jsx-dom.d.ts removed!'); -});