diff --git a/src/model/AssetMap.ts b/src/model/AssetMap.ts index b91d601..fbe174d 100644 --- a/src/model/AssetMap.ts +++ b/src/model/AssetMap.ts @@ -18,9 +18,13 @@ this.type = i.type; } - deserialise(): string { + deserialise(array = false): string { let parsed = JSON.parse(JSON.stringify(this)); parsed = sortObjectKeys(parsed); + + if(array) { + parsed = [parsed]; + } return JSON.stringify(parsed, undefined, 2); } } diff --git a/src/repo/index.ts b/src/repo/index.ts index 46594cb..a4f3924 100644 --- a/src/repo/index.ts +++ b/src/repo/index.ts @@ -131,7 +131,7 @@ export function addAssetMap(map: AssetMap, repoPath: string = DEFAULT_REPO_DISK_ } if(!fs.existsSync(assetMapInfoFile)) { - fs.writeFileSync(assetMapInfoFile, JSON.stringify([map.deserialise()], null, 2)); + fs.writeFileSync(assetMapInfoFile, map.deserialise(true)); return; } @@ -146,6 +146,6 @@ export function addAssetMap(map: AssetMap, repoPath: string = DEFAULT_REPO_DISK_ if(!existingMap) { assetMaps.push(map); - fs.writeFileSync(assetMapInfoFile, JSON.stringify(assetMaps.map(m => m.deserialise()), null, 2)); + fs.writeFileSync(assetMapInfoFile, JSON.stringify(assetMaps, null, 2)); } } \ No newline at end of file