-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (64 loc) · 2.36 KB
/
index.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
64
65
66
67
68
69
70
71
72
73
74
var fs = require('file-system');
var copydir = require('copy-dir');
const chalk = require('chalk');
const log = console.log;
var isError = false;
function copyFolder(folders, basePath, version, dev) {
if (folders !== undefined && folders.length > 0) {
folders.forEach(elm => {
var filePath = basePath + "/" + elm;
var copyPath = basePath + "/" + version + "/" + elm;
copydir(filePath, copyPath, function (err) {
if (err) {
log(chalk.red(err));
isError = true;
} else {
if (dev === true)
log(chalk.green('Copy Folder : ' + copyPath));
}
});
});
} else {
console.error("Error: Please Set Extension Folders.");
}
}
exports.init = function (c) {
console.log('\r\n');
if (c !== undefined) {
if (c.dev === undefined) {
c["dev"] = false;
}
if (c.version === undefined || c.version.trim() === "") {
console.error("Error: Please Set Version.");
} else if (c.files === undefined || c.files.length <= 0) {
console.error("Error: Please Set Extension Main Files.");
} else {
// Create Version Folder
fs.mkdir(c.basePath + "/" + c.version);
// Extension Files Copy
c.files.forEach(elm => {
var filePath = c.basePath + "/" + elm;
var copyPath = c.basePath + "/" + c.version + "/" + elm;
fs.copyFile(filePath, copyPath, {
done: function (err) {
if (err === null) {
if (c.dev === true)
log(chalk.green('Copy File : ' + copyPath));
} else {
isError = true;
log(chalk.red(err));
// console.error(err);
}
}
});
});
// Copy Folders
copyFolder(c.folders, c.basePath, c.version, c.dev);
// if (isError === false) {
// console.log("Your Extension Successfully Build.");
// } else {
// console.error("Error.");
// }
}
}
}