Skip to content

Commit

Permalink
print with indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FranciscoMoretti committed Sep 6, 2024
1 parent 2647ba2 commit ac5e438
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
18 changes: 12 additions & 6 deletions packages/download-notion/src/FilesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,25 @@ export class FilesManager {
}

public toJSON(): string {
return JSON.stringify({
baseFilesMap: this.baseFilesMap.getAll(),
outputDirectories: this.outputDirectories,
markdownPrefixes: this.markdownPrefixes,
})
return JSON.stringify(
{
baseFilesMap: this.baseFilesMap.getAll(),
outputDirectories: this.outputDirectories,
markdownPrefixes: this.markdownPrefixes,
},
null,
2
)
}

public static fromJSON(json: string): FilesManager {
const parsed = JSON.parse(json)
return new FilesManager({
outputDirectories: parsed.outputDirectories,
markdownPrefixes: parsed.markdownPrefixes,
initialFilesMap: FilesMap.fromJSON(JSON.stringify(parsed.baseFilesMap)),
initialFilesMap: FilesMap.fromJSON(
JSON.stringify(parsed.baseFilesMap, null, 2)
),
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/download-notion/src/FilesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ export class FilesMap {
}

toJSON(): string {
return JSON.stringify(this.map)
return JSON.stringify(this.map, null, 2)
}
}
2 changes: 0 additions & 2 deletions packages/download-notion/src/notionPull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,12 @@ export async function notionPull(options: NotionPullOptions): Promise<void> {

let imagesCacheFilesMap: FilesMap | undefined = undefined
if (options.cache.cacheImages) {
// TODO Read from previous filesmap file if available
const imagesCacheDir = cacheDir + "images/"
imagesCacheFilesMap =
loadImagesCacheFilesMap(imagesCacheDir + "images_filesmap.json") ||
new FilesMap()

await fetchImages(objectsTree, imagesCacheDir, imagesCacheFilesMap)
// Save to filesmap file
await saveToFile(
imagesCacheFilesMap.toJSON(),
imagesCacheDir + "images_filesmap.json"
Expand Down

0 comments on commit ac5e438

Please sign in to comment.