This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-release.js
54 lines (45 loc) · 1.68 KB
/
build-release.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
const path = require('path');
const fs = require('fs');
const archiver = require('archiver');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
// create stage and release folders
// delete stage and release files
try {
if (!fs.existsSync(path.join(__dirname, '/stage'))) {
fs.mkdirSync(path.join(__dirname, '/stage'));
}
if (!fs.existsSync(path.join(__dirname, '/release'))) {
fs.mkdirSync(path.join(__dirname, '/release'));
}
fs.unlinkSync(path.join(__dirname, '/release/release.zip'));
fs.unlinkSync(path.join(__dirname, '/stage/ITGlue.html'));
fs.unlinkSync(path.join(__dirname, '/stage/manifest.xml'));
fs.unlinkSync(path.join(__dirname, '/stage/Promote.png'));
} catch (e) {
}
webpack(webpackConfig, (err, stats) => {
if (err) {
console.error('Fatal error during compile.');
throw err;
}
// copy new build to stage
fs.copyFileSync(path.join(__dirname, '/dist/ITGlue.html'), path.join(__dirname, '/stage/ITGlue.html'));
fs.copyFileSync(path.join(__dirname, '/src/extension/manifest.xml'), path.join(__dirname, '/stage/manifest.xml'));
fs.copyFileSync(path.join(__dirname, '/src/extension/Promote.png'), path.join(__dirname, '/stage/Promote.png'));
buildZip();
});
function buildZip() {
const output = fs.createWriteStream(path.join(__dirname, '/release/release.zip'));
const archive = archiver('zip', {zlib: {level: 9}});
output.on('close', () => console.log('release.zip created.'));
archive.on('warning', (err) => {
console.warn(err);
});
archive.on('error', (err) => {
throw err;
});
archive.pipe(output);
archive.directory('stage/', '0e68472d-e8e4-4d7a-894e-c0eec88cf731');
archive.finalize();
}