-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbuild.js
More file actions
74 lines (59 loc) · 1.97 KB
/
build.js
File metadata and controls
74 lines (59 loc) · 1.97 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
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
#!/usr/bin/env node
import fs from 'fs/promises';
import path from 'path';
const SOURCE_DIR = './chrome-extension';
const DIST_DIR = './dist';
/**
* Recursively copy directory contents
*/
async function copyDirectory(src, dest) {
await fs.mkdir(dest, { recursive: true });
const entries = await fs.readdir(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
await copyDirectory(srcPath, destPath);
} else {
await fs.copyFile(srcPath, destPath);
}
}
}
/**
* Modify constants.js to set SERVER_PING_PERIOD_IN_MILLIS to 10 for integration tests
*/
async function modifyConstants() {
const constantsPath = path.join(DIST_DIR, 'constants.js');
let content = await fs.readFile(constantsPath, 'utf8');
// Replace SERVER_PING_PERIOD_IN_MILLIS value from 5000 to 10
content = content.replace(
/export const SERVER_PING_PERIOD_IN_MILLIS = 5000;/,
'export const SERVER_PING_PERIOD_IN_MILLIS = 10;'
);
await fs.writeFile(constantsPath, content, 'utf8');
console.log('✓ Modified SERVER_PING_PERIOD_IN_MILLIS to 10 for integration tests');
}
/**
* Main build function
*/
async function build() {
try {
// Clean dist directory
try {
await fs.rm(DIST_DIR, { recursive: true, force: true });
} catch (error) {
// Directory doesn't exist, that's fine
}
console.log('✓ Cleaned dist directory');
// Copy chrome-extension to dist
await copyDirectory(SOURCE_DIR, DIST_DIR);
console.log('✓ Copied chrome-extension to dist');
// Modify constants for integration tests
await modifyConstants();
console.log('✓ Build completed successfully');
} catch (error) {
console.error('Build failed:', error);
process.exit(1);
}
}
build();