Skip to content

Commit

Permalink
Fix build failing on windows in some unexplainable situations
Browse files Browse the repository at this point in the history
For some reason on windows cpSync throws error with code 'Unknown system error 17' instead of 'ENOENT'. Changing cpSync to async cp fixes the problem
  • Loading branch information
Exidex committed Aug 11, 2024
1 parent 0b25471 commit d85ac74
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function build(exit: boolean) {
}

try {
copyAssetData()
await copyAssetData()

writeDistManifest(manifestText)
} catch (error) {
Expand Down
7 changes: 4 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { InputOptions, OutputOptions, Plugin } from "rollup";
import nodeResolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "rollup-plugin-typescript2";
import { cpSync, readFileSync, writeFileSync } from "node:fs";
import { readFileSync, writeFileSync } from "node:fs";
import { cleandir } from "rollup-plugin-cleandir";
import { cp } from "node:fs/promises";

// needs to be valid and properly cased js identifier
const preferenceName = z.string()
Expand Down Expand Up @@ -237,9 +238,9 @@ export function writeDistManifest(manifestText: string) {
writeFileSync("dist/gauntlet.toml", manifestText)
}

export function copyAssetData() {
export async function copyAssetData() {
try {
cpSync("assets", "dist/assets", { recursive: true });
await cp("assets", "dist/assets", { recursive: true });
} catch (err) {
if ((err as any).code === 'ENOENT') {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export async function dev() {
break;
}

copyAssetData()
await copyAssetData()

writeDistManifest(manifestText)

Expand Down

0 comments on commit d85ac74

Please sign in to comment.