-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy-deps.js
More file actions
44 lines (34 loc) · 1.46 KB
/
copy-deps.js
File metadata and controls
44 lines (34 loc) · 1.46 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
#!/usr/bin/env node
/**
* Copy third-party dependencies from node_modules to js/lib directory
* This script replaces the previous copy-deps.sh shell script
*/
import { cpSync, mkdirSync, rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
// Remove and recreate js/lib directory
const libDir = join(__dirname, 'lib')
rmSync(libDir, { recursive: true, force: true })
mkdirSync(libDir, { recursive: true })
/**
* Copy a file from node_modules to js/lib directory
* @param {string} source - Source path relative to project root
* @param {string} destination - Destination filename in js/lib directory
*/
function copyDependency (source, destination) {
const sourcePath = join(__dirname, source)
const destPath = join(libDir, destination)
cpSync(sourcePath, destPath, { recursive: true })
console.log(`Copied ${source} -> lib/${destination}`)
}
// custom element polyfill for safari
copyDependency('./node_modules/@ungap/custom-elements/es.js', 'custom-elements.js')
// 3d model viewing
copyDependency('./node_modules/@google/model-viewer/dist/model-viewer.min.js', 'model-viewer.min.js')
// 3D web scenes
copyDependency('./node_modules/aframe/dist', 'aframe')
copyDependency('./node_modules/buffer/index.js', 'buffer/index.js')
// gamepad library
copyDependency('node_modules/gameinputjs', 'gameinputjs')
console.log('All dependencies copied successfully!')