Skip to content

Commit

Permalink
fs.cp isn't available on stable nodejs@14 yet
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Apr 8, 2022
1 parent 5c0f82c commit 2f0363b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions build/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,21 @@ commands.build.rust = async function (argv) {
await checkWasmSize(paths.wasm.mainGz, limitMb)
}
// Copy WASM files from temporary directory to Webpack's `dist` directory.
await fs.cp(paths.wasm.root, paths.dist.wasm.root, { recursive: true })
await copyRecursively(paths.wasm.root, paths.dist.wasm.root, { recursive: true })
}

async function copyRecursively(src, dest, opts) {
var stats = await fs.stat(src);
var isDirectory = stats && stats.isDirectory();
if (isDirectory) {
await fs.mkdir(dest, opts)
let names = await fs.readdir(src)
for (let n of names) {
await copyRecursive(path.join(src, n), path.join(dest, n))
}
} else {
await fs.copyFile(src, dest)
}
}

// Check if compressed WASM binary exceeds the size limit.
Expand Down Expand Up @@ -630,7 +644,7 @@ async function downloadJsAssets() {

const assetsArchive = await unzipper.Open.file(path.join(workdir, ideAssetsMainZip))
await assetsArchive.extract({ path: workdir })
await fs.cp(unzippedAssets, jsLibAssets, { recursive: true })
await copyRecursively(unzippedAssets, jsLibAssets, { recursive: true })
await fs.rm(workdir, { recursive: true, force: true })
}

Expand Down

0 comments on commit 2f0363b

Please sign in to comment.