forked from ionic-team/ionic-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-core.js
63 lines (52 loc) · 1.88 KB
/
build-core.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const fs = require('fs-extra');
const path = require('path');
const spawn = require('child_process').spawn;
const stencilPath = path.join(__dirname, '..', '..', 'core', 'node_modules', '.bin');
const typescriptPath = path.join(__dirname, '..', 'node_modules', '.bin');
function copyIonicons() {
const src = path.join(__dirname, '..', '..', 'core', 'node_modules', 'ionicons');
const dst = path.join(__dirname, '..', 'node_modules', 'ionicons');
fs.removeSync(dst);
fs.copySync(src, dst);
}
function copyCSS() {
const src = path.join(__dirname, '..', '..', 'core', 'css');
const dst = path.join(__dirname, '..','dist', 'css');
fs.removeSync(dst);
fs.copySync(src, dst);
}
function buildSchematics(){
return new Promise((resolve, reject) => {
const cmd = 'tsc';
const args = [
'--project',
path.join(__dirname, '..', 'tsconfig.schematics.json'),
];
const p = spawn(cmd, args, { cwd: typescriptPath, stdio: 'inherit', shell: true });
p.on('close', (code) => {
if (code > 0) {
console.log(`ng-add build exited with ${code}`);
reject();
} else {
resolve();
}
});
});
}
function copySchematicsJson(){
const src = path.join(__dirname, '..', 'src', 'schematics', 'collection.json');
const fileSrc = path.join(__dirname, '..', 'src', 'schematics', 'add', 'files');
const dst = path.join(__dirname, '..', 'dist','schematics', 'collection.json');
const fileDst = path.join(__dirname, '..', 'dist', 'schematics', 'add', 'files');
const schemaSrc = path.join(__dirname, '..', 'src', 'schematics', 'add', 'schema.json');
const schemaDst = path.join(__dirname, '..', 'dist', 'schematics', 'add', 'schema.json');
fs.removeSync(dst);
fs.removeSync(fileDst);
fs.copySync(src, dst);
fs.copySync(fileSrc,fileDst);
fs.copySync(schemaSrc, schemaDst);
}
copyIonicons();
copyCSS();
buildSchematics();
copySchematicsJson()