-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-template.mjs
More file actions
25 lines (21 loc) · 930 Bytes
/
Copy pathsync-template.mjs
File metadata and controls
25 lines (21 loc) · 930 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
25
// Copies the single-source-of-truth template payload from the repo root
// (`../template`) into this package (`./template`) so it ships inside the
// published tarball and is resolvable at runtime next to `dist/`.
import { cp, rm } from 'node:fs/promises'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const here = dirname(fileURLToPath(import.meta.url))
const cliRoot = resolve(here, '..')
const source = resolve(cliRoot, '..', 'template')
const dest = resolve(cliRoot, 'template')
// Never copy generated/dependency artifacts even if a dirty checkout has them.
const EXCLUDE = new Set(['node_modules', 'dist', 'dist-tsc', '.yarn'])
await rm(dest, { recursive: true, force: true })
await cp(source, dest, {
recursive: true,
filter: (src) => {
const name = src.split(/[/\\]/).pop()
return !name || !EXCLUDE.has(name)
},
})
console.error(`[sync-template] ${source} → ${dest}`)