-
Notifications
You must be signed in to change notification settings - Fork 14
/
package.js
44 lines (34 loc) · 923 Bytes
/
package.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
/* global require, console */
/* eslint no-console: off */
var fs = require("fs");
var normalizePath = require("path").normalize;
var info = JSON.parse("" + fs.readFileSync("package.json"));
var source = normalizePath("export/");
var destination = normalizePath('packages/');
var destinationFile = normalizePath(destination + "/WebStory-Engine-v" + info.version + ".zip");
var archiver = require('archiver');
var archive = archiver('zip');
mkdirSync(destination);
var output = fs.createWriteStream(destinationFile);
archive.pipe(output);
archive.bulk([{
src: ['**/*'],
cwd: source,
expand: true
}]);
archive.finalize(function(err) {
if (err) {
throw err;
}
console.log('Created ZIP file in packages/.');
});
function mkdirSync (path) {
try {
fs.mkdirSync(path);
}
catch (e) {
if (e.code != 'EEXIST') {
throw e;
}
}
}