-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
46 lines (35 loc) · 1.38 KB
/
build.js
File metadata and controls
46 lines (35 loc) · 1.38 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
#!/usr/bin/env node
import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, '..');
const browser = process.argv[2];
if (!browser || !['chrome', 'firefox'].includes(browser)) {
console.error('Usage: node build.js [chrome|firefox]');
process.exit(1);
}
const OUTPUT_DIR = path.join(ROOT, 'build', browser, 'assets', 'vendor');
async function buildVendor() {
console.log(`Building vendor dependencies for ${browser}...`);
// Relative time source from node_modules (use bundle.js, not index.js)
const source = path.join(ROOT, 'node_modules', '@github', 'relative-time-element', 'dist', 'bundle.js');
// Check if dependency is installed
try {
await fs.access(source);
} catch {
console.error('ERROR: @github/relative-time-element not found in node_modules.');
console.error('Run: npm install');
process.exit(1);
}
// Create output directory
await fs.mkdir(OUTPUT_DIR, { recursive: true });
// Copy the relative time source bundle file to vendor, renaming for clarity.
const dest = path.join(OUTPUT_DIR, 'relative-time-element.js');
await fs.copyFile(source, dest);
console.log(`✓ Vendor dependencies built for ${browser}`);
}
buildVendor().catch(err => {
console.error('Vendor build failed:', err);
process.exit(1);
});