-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathbuild-zip.js
More file actions
37 lines (29 loc) · 1.11 KB
/
Copy pathbuild-zip.js
File metadata and controls
37 lines (29 loc) · 1.11 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
import { execSync } from 'child_process'
import { resolve, dirname } from 'path'
import { existsSync, renameSync, unlinkSync, rmSync } from 'fs'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const root = resolve(__dirname, '..')
const target = process.argv[2]
if (!target) {
console.error('Usage: node scripts/build-zip.js <target-dir>')
process.exit(1)
}
const srcDir = resolve(root, target, 'drplayer')
const zipFile = resolve(root, target, 'drplayer.zip')
const finalFile = resolve(root, target, 'drplayer')
if (!existsSync(srcDir)) {
console.error(`Source directory not found: ${srcDir}`)
process.exit(1)
}
// Remove leftover zip if exists
if (existsSync(zipFile)) unlinkSync(zipFile)
// Compress contents of srcDir (no nesting — files go directly into zip root)
execSync(
`powershell -Command "Compress-Archive -Path '${srcDir}\\*' -DestinationPath '${zipFile}'"`,
{ stdio: 'inherit' }
)
// Remove the source directory, then rename zip to final name
rmSync(srcDir, { recursive: true, force: true })
renameSync(zipFile, finalFile)
console.log(`Done: ${finalFile}`)