-
Notifications
You must be signed in to change notification settings - Fork 1
/
package.js
57 lines (48 loc) · 1.53 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
const fs = require('fs');
function createDir(location, name) {
const binDir = fs.readdirSync(location);
if (!binDir.includes(name)) {
console.log(`Creating:\t${location}/${name}`);
fs.mkdirSync(`${location}/${name}`);
}
}
function linkDir(uri, outputUri) {
try {
fs.mkdirSync(outputUri);
} catch (err) {
}
const dir = fs.readdirSync(uri, {withFileTypes: true});
for (const fileDirent of dir)
if (fileDirent.isFile())
try {
console.log(`Linking ${uri}/${fileDirent.name} -> ${outputUri}/${fileDirent.name}`);
fs.linkSync(`${uri}/${fileDirent.name}`, `${outputUri}/${fileDirent.name}`);
} catch (err) {
}
else if (fileDirent.isDirectory())
linkDir(`${uri}/${fileDirent.name}`, `${outputUri}/${fileDirent.name}`);
}
function linkFile(file, newPath) {
console.log(`Linking ${file} -> ${newPath}`);
try {
fs.linkSync(file, newPath);
} catch (err) {
}
}
console.log('Cleaning and creating unpacked dirs...');
try {
fs.rmdirSync('./bin/unpackaged');
} catch (err) {
}
createDir('./', 'bin');
createDir('./bin', 'unpackaged');
createDir('./bin/unpackaged', 'src');
console.log('\nLinking assets...');
linkDir('./assets', './bin/unpackaged/assets');
linkDir('./src/backend', './bin/unpackaged/src/backend');
console.log('\nLinking package json files...');
linkFile('./package.json', './bin/unpackaged/package.json');
linkFile('./package-lock.json', './bin/unpackaged/package-lock.json');
linkFile('./LICENSE', './bin/unpackaged/LICENSE');
linkFile('./constants.json', './bin/unpackaged/constants.json');
console.log('\n');