Skip to content

Commit

Permalink
ci: try copyFile.
Browse files Browse the repository at this point in the history
  • Loading branch information
knightedcodemonkey committed Jun 30, 2024
1 parent 239f709 commit e5bfc29
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/duel.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env node

import { argv, platform } from 'node:process'
import { join, dirname, resolve, relative } from 'node:path'
import { join, dirname, resolve, relative, parse } from 'node:path'
import { spawn } from 'node:child_process'
// eslint-disable-next-line n/no-unsupported-features/node-builtins
import { writeFile, rm, rename, cp, mkdir } from 'node:fs/promises'
import { writeFile, rm, rename, mkdir, copyFile, lstat } from 'node:fs/promises'
import { randomBytes } from 'node:crypto'
import { performance } from 'node:perf_hooks'

Expand Down Expand Up @@ -147,8 +146,22 @@ const duel = async args => {
dualConfigPath = join(subDir, `tsconfig.${hex}.json`)
await mkdir(subDir)
await Promise.all(
compileFiles.map(file =>
cp(file, join(subDir, relative(projectDir, file).replace(/^(\.\.\/)*/, '')), { recursive: true }),
compileFiles.map(async file =>
{
const dest = join(subDir, relative(projectDir, file).replace(/^(\.\.\/)*/, ''))
const { dir } = parse(dest)

try {
await lstat(dir)
} catch (err) {
if (err.code === 'ENOENT') {
await mkdir(dir, { recursive: true })
}
}

return copyFile(file, dest)
}
//cp(file, join(subDir, relative(projectDir, file).replace(/^(\.\.\/)*/, ''))),
),
)

Expand Down

0 comments on commit e5bfc29

Please sign in to comment.