forked from fixer112/Honeypays
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.js
34 lines (29 loc) · 1.12 KB
/
prepare.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs-extra');
const path = require('path');
const {execSync} = require('child_process');
const winston = require('winston-color');
const distPath = path.resolve(__dirname, './dist');
const tplPath = path.resolve(__dirname, './template');
const appPackage = require('./package.json');
const tplPackage = require('./template/package.json');
function copyNativeScriptPlugins () {
winston.info('Copying NativeScript plugins to template dependencies...');
const plugins = Object.keys(appPackage.dependencies)
.filter(key => key.indexOf('nativescript-') !== -1)
.reduce((obj, key) => {
obj[key] = appPackage.dependencies[key];
return obj;
}, {});
Object.assign(tplPackage.dependencies, plugins);
fs.writeFileSync(tplPath + '/package.json', JSON.stringify(tplPackage, null, 2));
}
function updateDistFromTemplate () {
winston.info('Preparing NativeScript application from template...');
fs.ensureDirSync(distPath);
fs.copySync(tplPath, distPath, {overwrite: false});
execSync('npm i', {cwd: 'dist'});
}
module.exports = () => {
copyNativeScriptPlugins();
updateDistFromTemplate();
};