@sf-kmods/kdataforgejs-cli 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,8 @@ import { detectGameInstallations, resolveGameInstallation, supportedPlatform } f
6
6
  const DEFAULT_TIMEOUT_MILLISECONDS = 15 * 60 * 1_000;
7
7
  const POLL_INTERVAL_MILLISECONDS = 500;
8
8
  export async function importGameData(options, dependencies = {}) {
9
+ const timeoutMilliseconds = options.timeoutMilliseconds ?? DEFAULT_TIMEOUT_MILLISECONDS;
10
+ assertValidTimeout(timeoutMilliseconds);
9
11
  const platform = supportedPlatform(dependencies.platform ?? process.platform);
10
12
  const installation = selectInstallation(options.gamePath, platform);
11
13
  const destination = resolve(options.destination);
@@ -13,7 +15,7 @@ export async function importGameData(options, dependencies = {}) {
13
15
  try {
14
16
  const plan = createLaunchPlan(installation, platform, exportDirectory);
15
17
  await (dependencies.launch ?? launchGame)(plan);
16
- const artifacts = await waitForExport(exportDirectory, options.timeoutMilliseconds ?? DEFAULT_TIMEOUT_MILLISECONDS, dependencies.sleep ?? delay);
18
+ const artifacts = await waitForExport(exportDirectory, timeoutMilliseconds, dependencies.sleep ?? delay);
17
19
  return installExport(destination, installation, artifacts);
18
20
  }
19
21
  finally {
@@ -68,9 +70,7 @@ async function launchGame(plan) {
68
70
  });
69
71
  }
70
72
  async function waitForExport(exportDirectory, timeoutMilliseconds, sleep) {
71
- if (!Number.isSafeInteger(timeoutMilliseconds) || timeoutMilliseconds <= 0) {
72
- throw new Error("Game-data timeout must be a positive integer number of milliseconds.");
73
- }
73
+ assertValidTimeout(timeoutMilliseconds);
74
74
  const deadline = Date.now() + timeoutMilliseconds;
75
75
  while (Date.now() <= deadline) {
76
76
  const artifacts = findCompletedExport(exportDirectory);
@@ -80,6 +80,11 @@ async function waitForExport(exportDirectory, timeoutMilliseconds, sleep) {
80
80
  }
81
81
  throw new Error(`Timed out after ${timeoutMilliseconds} ms waiting for KDataForge reflection export.`);
82
82
  }
83
+ function assertValidTimeout(timeoutMilliseconds) {
84
+ if (!Number.isSafeInteger(timeoutMilliseconds) || timeoutMilliseconds <= 0) {
85
+ throw new Error("Game-data timeout must be a positive integer number of milliseconds.");
86
+ }
87
+ }
83
88
  function findCompletedExport(exportDirectory) {
84
89
  const archive = readdirSync(exportDirectory, { withFileTypes: true })
85
90
  .filter((entry) => entry.isFile() && entry.name.toLocaleLowerCase().endsWith(".kdfdata"))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sf-kmods/kdataforgejs-cli",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "kdf - create, type-check and validate KDataForge projects with KDataForgeJS (TypeScript) scripts.",
5
5
  "license": "MIT",
6
6
  "author": "Kyri123/Kyrium",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "typescript": ">=5.7.3 <6",
38
38
  "yaml": "^2.6.1",
39
- "@sf-kmods/kdataforgejs": "^0.1.17"
39
+ "@sf-kmods/kdataforgejs": "^0.1.18"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^22.10.0"