-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
30 lines (23 loc) · 881 Bytes
/
build.js
File metadata and controls
30 lines (23 loc) · 881 Bytes
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
const fs = require('fs');
if (process.argv.length < 3) {
console.error('Please provide the file path as an argument.');
process.exit(1);
}
const filePath = process.argv[2];
if (!fs.existsSync(filePath)) {
console.error(`The file ${filePath} does not exist.`);
process.exit(1);
}
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file ${filePath}: ${err}`);
return;
}
let result = data.replace(/class AvalynxRef /g, 'import * as bootstrap from \'bootstrap\';\n\nexport class AvalynxRef ');
result = result.replace(/\n\nif \(typeof module !== 'undefined' && module\.exports\) \{\n module\.exports = AvalynxRef;\n\}\n?$/, '');
fs.writeFile(filePath, result, 'utf8', err => {
if (err) {
console.error(`Error writing file ${filePath}: ${err}`);
}
});
});