collect-state: Support dir/<device>.json independent of multi-device

This commit is contained in:
Danny Lin 2021-12-21 19:52:16 -08:00
parent fbf152fb63
commit 830d5e939e

View file

@ -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))
})
}