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