-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ts
More file actions
24 lines (18 loc) · 806 Bytes
/
Copy pathbuild.ts
File metadata and controls
24 lines (18 loc) · 806 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
import { execSync } from 'node:child_process'
import { mkdirSync, rmSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = dirname(fileURLToPath(import.meta.url))
// Clean dist directory
rmSync(join(__dirname, 'dist'), { recursive: true, force: true })
mkdirSync(join(__dirname, 'dist'), { recursive: true })
// Compile TypeScript
console.log('Compiling TypeScript...')
execSync('npx tsc', { stdio: 'inherit', cwd: __dirname })
// The shebang is already in the source file, just make it executable
let distFile = join(__dirname, 'dist/index.js')
execSync(`chmod +x ${distFile}`)
// Remove test files from dist
console.log('Removing test files...')
execSync('rm -f dist/*.test.js', { cwd: __dirname })
console.log('Build complete!')