From 83fb1932263747b2d5e78fdb26c826678e99b12b Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Wed, 21 Mar 2018 15:58:18 +0100 Subject: [PATCH] Many plugins use hooks to run before/after prepare scripts. Firebase being one of those. This change copies the hooks folder (if any) to the dist folder. Without this change, the Firebase plugin will not run at all on Android, and have trouble with certain features on iOS. Also, users can now add their own hooks to the root /hooks folder, and those are picked up as well. --- template/prepare.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/prepare.js b/template/prepare.js index 5e2a078..f847ca5 100644 --- a/template/prepare.js +++ b/template/prepare.js @@ -5,6 +5,7 @@ const winston = require('winston-color'); const distPath = path.resolve(__dirname, './dist'); const tplPath = path.resolve(__dirname, './template'); +const hooksPath = path.resolve(__dirname, './hooks'); const appPackage = require('./package.json'); const tplPackage = require('./template/package.json'); @@ -25,6 +26,9 @@ function updateDistFromTemplate () { winston.info('Preparing NativeScript application from template...'); fs.ensureDirSync(distPath); fs.copySync(tplPath, distPath, {overwrite: false}); + if (fs.existsSync(hooksPath)) { + fs.copySync(hooksPath, path.join(distPath, "hooks")); + } execSync('npm i', {cwd: 'dist'}); }