-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.js
More file actions
49 lines (43 loc) · 1.47 KB
/
Copy pathbuild.js
File metadata and controls
49 lines (43 loc) · 1.47 KB
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
const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');
if (!process.argv.includes('fast')) {
if (!fs.existsSync('compiler/build/')) {
fs.mkdirSync('compiler/build/')
}
if (!fs.existsSync('compiler/build/std')) {
fs.mkdirSync('compiler/build/std')
}
}
execSync('npm run build', { cwd: 'compiler' });
copyFilesRecur('std', 'compiler/build/std', ['.chad']);
if (!process.argv.includes('fast')) {
execSync('npm install', { cwd: 'compiler' });
execSync('npm install', { cwd: 'vscode' });
execSync('npm run build', { cwd: 'vscode' });
let compilerDir = process.cwd() + '/' + 'compiler/build/index.js'
fs.writeFileSync('chad', `NODE_OPTIONS=--enable-source-maps node ${compilerDir} $@`);
fs.chmodSync('chad', 0o700);
console.log('build complete. to install cp ./chad to /bin')
}
function copyFilesRecur(srcDir, targetDir, extensions) {
let files = fs.readdirSync(srcDir)
for (let file of files) {
const srcFilePath = path.join(srcDir, file);
const targetFilePath = path.join(targetDir, file);
let stats = fs.statSync(srcFilePath);
if (stats.isDirectory()) {
if (!fs.existsSync(targetFilePath)) {
fs.mkdirSync(targetFilePath);
}
copyFilesRecur(srcFilePath, targetFilePath, extensions);
}
else {
for (let extension of extensions) {
if (srcFilePath.endsWith(extension)) {
fs.copyFileSync(srcFilePath, targetFilePath);
}
}
}
};
}