mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Stream JSON lists to file one line at a time
This commit is contained in:
parent
ea40288bea
commit
d497c12c99
1 changed files with 4 additions and 7 deletions
|
|
@ -51,6 +51,9 @@ import {
|
||||||
import {
|
import {
|
||||||
cliOptions
|
cliOptions
|
||||||
} from '~/helpers/cli-options.js'
|
} from '~/helpers/cli-options.js'
|
||||||
|
import {
|
||||||
|
streamToJson
|
||||||
|
} from '~/helpers/json.js'
|
||||||
|
|
||||||
// Setup dotenv
|
// Setup dotenv
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
@ -279,13 +282,7 @@ class BuildLists {
|
||||||
|
|
||||||
const saveableList = saveMethod( this.lists[listOptions.name] )
|
const saveableList = saveMethod( this.lists[listOptions.name] )
|
||||||
|
|
||||||
// console.log('saveableList', typeof saveableList)
|
await streamToJson( saveableList, listFullPath )
|
||||||
|
|
||||||
// Stringify one at a time to allow for large lists
|
|
||||||
const saveableListJSON = '[' + saveableList.map(el => JSON.stringify(el)).join(',') + ']'
|
|
||||||
|
|
||||||
// Write the list to JSON
|
|
||||||
await fs.writeFile(listFullPath, saveableListJSON)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue