Skip to content

Commit acda1c4

Browse files
committed
refactor: moved the wasm copy to a separate file.
1 parent 2bc4658 commit acda1c4

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"lint": "bun run --filter \"*\" lint",
99
"typecheck": "bun run --filter \"*\" typecheck",
1010
"build:wasm": "bun ./scripts/cargo-msfs.ts",
11+
"copy:wasm": "bun run ./scripts/copy-wasm-module.ts",
12+
"build": "bun run build:wasm && bun run copy:wasm",
1113
"package": "bestzip wasm.zip dist/wasm/*"
1214
},
1315
"devDependencies": {

scripts/cargo-msfs.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { $ } from "bun";
2-
import { constants, copyFile, existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
2+
import { existsSync, mkdirSync, readFileSync, rmdirSync } from "node:fs";
33
import { dirname, join, normalize, resolve } from "node:path";
44

55
/// The type returned from the `cargo-msfs info -f` command
@@ -67,10 +67,6 @@ if (installedSdks.versions.some(v => !v.up_to_date)) {
6767

6868
// Clear out dir
6969
const outDir = resolve(workspaceRoot, "dist/wasm");
70-
const panelDir = resolve(
71-
workspaceRoot,
72-
"example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel",
73-
);
7470

7571
if (existsSync(outDir)) rmdirSync(outDir, { recursive: true });
7672

@@ -101,17 +97,3 @@ await $`docker run \
10197
console.error(`[-] Error building for ${simVersion}: ${err.exitCode} ${err.stderr?.toString()}`);
10298
process.exit(1);
10399
});
104-
105-
copyFile(
106-
`${join(simDir, "msfs_navigation_data_interface.wasm")}`,
107-
`${join(panelDir, "msfs_navigation_data_interface.wasm")}`,
108-
constants.COPYFILE_FICLONE,
109-
err => {
110-
if (err) {
111-
console.error("[-] Wasm module copy failed ");
112-
process.exit(1);
113-
}
114-
115-
console.info(`[*] Copying WASM module to aircraft panel folder`);
116-
},
117-
);

scripts/copy-wasm-module.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { copyFile } from "node:fs";
2+
import { join, resolve } from "node:path";
3+
4+
const rootDir = resolve(__dirname, "..");
5+
6+
const wasmModuleDir = join(rootDir, "dist/wasm/2020/msfs_navigation_data_interface.wasm");
7+
const panelDir = join(
8+
rootDir,
9+
"example/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navigation_Data_Interface_Aircraft/panel/msfs_navigation_data_interface.wasm",
10+
);
11+
12+
copyFile(wasmModuleDir, panelDir, err => {
13+
if (err) {
14+
console.error(`[-] Wasm module copy failed: ${err.message}`);
15+
process.exit(1);
16+
}
17+
18+
console.info(`[*] Copying WASM module to aircraft panel folder`);
19+
});

0 commit comments

Comments
 (0)