-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
116 lines (104 loc) · 2.91 KB
/
build.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
(() => {
"use strict";
/* eslint-disable no-console */
/* global Func, path */
global.modulePath = __dirname + "/node_modules/";
try {
require("../node.js_Build/funcs");
} catch (e) {
if (e.code !== "MODULE_NOT_FOUND") {
throw e;
}
console.error("Build script is missing. Please download from https://github.com/Kiuryy/node.js_Build");
process.exit(1);
}
// SCSS Filewatcher -> <PATH_TO_node>/npm.cmd run scss
/**
* Starts building the application
*/
const Build = () => {
const start = +new Date();
console.log("Building release...\n");
Func.cleanPre().then(() => {
return eslintCheck();
}).then(() => {
}).then(() => {
return js();
}).then(() => {
return css();
}).then(() => {
return img();
}).then(() => {
return Func.cleanPost();
}).then(() => {
console.log("\nRelease built successfully\t[" + (+new Date() - start) + " ms]");
});
};
/*
* ################################
* BUILD FUNCTIONS
* ################################
*/
/**
* Parses the scss files and copies the css files to the dist directory
*
* @returns {Promise}
*/
const css = () => {
return new Promise((resolve) => {
Func.minify([ // parse scss files
path.src + "scss/*.scss"
], path.dist + "css/").then(() => {
resolve();
});
});
};
/**
* Copies the images to the dist directory
*
* @returns {Promise}
*/
const img = () => {
return new Promise((resolve) => {
Func.copy([path.src + "img/**/*"], [path.src + "**/*.xcf"], path.dist, false).then(() => {
resolve();
});
});
};
/**
* Parses the js files and copies them to the dist directory
*
* @returns {Promise}
*/
const js = () => {
return new Promise((resolve) => {
Func.minify([
path.src + "js/*.js"
], path.dist + "js/").then(() => {
resolve();
});
});
};
/**
* Performs eslint checks for the build and src/js directories
*
* @returns {Promise}
*/
const eslintCheck = async () => {
for (const files of ["build.js", path.src + "js/**/*.js"]) {
await Func.measureTime(async (resolve) => {
Func.cmd("eslint --fix " + files).then((obj) => {
if (obj.stdout && obj.stdout.trim().length > 0) {
console.error(obj.stdout);
process.exit(1);
}
resolve();
});
}, "Performed eslint check for " + files);
}
};
//
//
//
Build();
})();