From 830d5e939ea2cb7530654f2a3a54a859ba48d7a3 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Tue, 21 Dec 2021 19:52:16 -0800 Subject: [PATCH] collect-state: Support dir/.json independent of multi-device --- src/commands/collect-state.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/collect-state.ts b/src/commands/collect-state.ts index 5c5e0a9..9d93286 100644 --- a/src/commands/collect-state.ts +++ b/src/commands/collect-state.ts @@ -27,11 +27,12 @@ export default class CollectState extends Command { parallel, }, args: {output_path: outPath}} = this.parse(CollectState) + let isDir = (await fs.stat(outPath)).isDirectory() await forEachDevice(devices, parallel, async (device) => { let state = await collectSystemState(device, outRoot, aapt2Path) // Write - let devicePath = devices.length > 1 ? `${outPath}/${device}.json` : outPath + let devicePath = isDir ? `${outPath}/${device}.json` : outPath await fs.writeFile(devicePath, serializeSystemState(state)) }) }