-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.js
29 lines (27 loc) · 983 Bytes
/
publish.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
const fs = require('fs');
const path = require('path');
const fse = require('fs-extra');
const exec = require('child_process').exec;
const config = require('./shark-automation-config.js');
const publishDir = 'dist';
const publishFile = 'shark-angularjs.ui.js';
fse.ensureDirSync(config.build);
fse.emptyDirSync(config.build);
fse.ensureDirSync(publishDir);
fse.emptyDirSync(publishDir);
exec('npm run build', function (err, stdout, stderr) {
if (err) {
console.log('error:' + err);
} else {
fse.copySync(path.join(config.build, config.buildStatic, config.staticVersion, config.jsDistPath), publishDir);
var files = fs.readdirSync(publishDir);
files && files.forEach((item) => {
if (item.indexOf('shark') > -1) {
fse.move(path.join(publishDir, item), path.join(publishDir, publishFile));
}
else {
fse.remove(path.join(publishDir, item));
}
});
}
});