fortnite-replay-analysis 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/index.js +18 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const os = require('os');
2
+ const fs = require('fs');
2
3
  const path = require('path');
3
4
  const Decimal = require('decimal.js');
4
5
  const { execFile } = require('child_process');
@@ -16,8 +17,24 @@ function getBinaryPath() { // OS判定して自己完結バイナリの実行フ
16
17
  }
17
18
  }
18
19
 
19
- function ReplayAnalysis(replayFilePath, { bot = false, sort = true } = {}) { // Fortniteのリプレイファイルを解析してプレイヤーデータを返す
20
+ function ReplayAnalysis(replayFileDir, { bot = false, sort = true } = {}) { // Fortniteのリプレイファイルを解析してプレイヤーデータを返す
20
21
  return new Promise((resolve, reject) => {
22
+
23
+ let replayFiles;
24
+ try {
25
+ replayFiles = fs.readdirSync(replayFileDir).filter(f => f.endsWith('.replay'));
26
+ } catch (e) {
27
+ reject(new Error(`Failed to read directory: ${e.message}`));
28
+ return;
29
+ }
30
+
31
+ if (replayFiles.length === 0) {
32
+ reject(new Error(`No replay file found in directory: ${replayFileDir}`));
33
+ return;
34
+ }
35
+
36
+ // とりあえず1個目のファイルを処理(複数ある場合は要拡張)
37
+ const replayFilePath = path.join(replayFileDir, replayFiles[0]);
21
38
  const binPath = getBinaryPath();
22
39
 
23
40
  execFile(binPath, [replayFilePath], (error, stdout, stderr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fortnite-replay-analysis",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Fortniteのリプレイ解析をNode.jsから呼べる自己完結型C#バイナリラッパー",
5
5
  "repository": {
6
6
  "type": "git",