-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path__PACK.js
111 lines (89 loc) · 2.24 KB
/
__PACK.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
// load UPPERCASE.
require('./node.index.js');
INIT_OBJECTS();
/*
* pack UPPERCASE.
*/
RUN(() => {
const TITLE = 'UPPERCASE';
const BASE_CONTENT = '\'use strict\';\n\n/*\n * Welcome to ' + TITLE + '! (http://uppercase.io)\n */\n\n';
let log = (msg) => {
console.log(TITLE + ' PACK: ' + msg);
};
let collect = (path, pre) => {
//REQUIRED: path
//OPTIONAL: path
let scripts = pre === undefined ? [] : pre;
FIND_FILE_NAMES({
path: './SRC/' + path,
isSync: true
}, {
notExists: () => {
// ignore.
},
success: (fileNames) => {
EACH(fileNames, (fileName) => {
if (scripts.includes(path + '/' + fileName) !== true) {
scripts.push(path + '/' + fileName);
}
});
}
});
FIND_FOLDER_NAMES({
path: './SRC/' + path,
isSync: true
}, {
notExists: () => {
// ignore.
},
success: (folderNames) => {
EACH(folderNames, (folderName) => {
scripts = scripts.concat(collect(path + '/' + folderName, pre));
});
}
});
return scripts;
};
log('START.');
let commonScriptPaths = collect('COMMON',
// FOR_BOX를 위한 사전 로드
[
'COMMON/TO_DELETE.js',
'COMMON/METHOD.js',
'COMMON/UTIL/DATA/CHECK_IS_DATA.js',
'COMMON/UTIL/ARRAY/CHECK_IS_ARRAY.js',
'COMMON/UTIL/REPEAT/EACH.js',
'COMMON/BOX/BOX.js',
'COMMON/BOX/FOR_BOX.js'
]
);
let browserScriptPaths = commonScriptPaths.concat(collect('BROWSER'));
let nodeScriptPaths = commonScriptPaths.concat(collect('NODE'));
let browserScript = BASE_CONTENT;
browserScript += '// 웹 브라우저 환경에서는 window가 global 객체 입니다.\n';
browserScript += 'let global = window;\n\n';
EACH(browserScriptPaths, (path) => {
browserScript += READ_FILE({
path: './SRC/' + path,
isSync: true
}).toString() + '\n';
});
let nodeIndexScript = BASE_CONTENT;
EACH(nodeScriptPaths, (path) => {
nodeIndexScript += 'require(\'./SRC/' + path + '\');\n';
});
nodeIndexScript += '\nmodule.exports = (value) => {\n';
nodeIndexScript += ' return String(value).toUpperCase();\n';
nodeIndexScript += '};\n';
WRITE_FILE({
path: './UPPERCASE.js',
content: browserScript,
isSync: true
});
WRITE_FILE({
path: './node.index.js',
content: nodeIndexScript,
isSync: true
});
log('DONE.');
});