@@ -182,8 +182,8 @@ function sortBlocks(blocksByTitle, blockIndices) {
182
182
) ;
183
183
}
184
184
185
- function encodeSnapshots ( snapshotData ) {
186
- const encoded = cbor . encodeOne ( snapshotData , {
185
+ async function encodeSnapshots ( snapshotData ) {
186
+ const encoded = await cbor . encodeAsync ( snapshotData , {
187
187
omitUndefinedProperties : true ,
188
188
canonical : true ,
189
189
} ) ;
@@ -351,7 +351,7 @@ class Manager {
351
351
this . recordSerialized ( { belongsTo, index, ...snapshot } ) ;
352
352
}
353
353
354
- save ( ) {
354
+ async save ( ) {
355
355
const { dir, relFile, snapFile, snapPath, reportPath} = this ;
356
356
357
357
if ( this . updating && this . newBlocksByTitle . size === 0 ) {
@@ -371,15 +371,17 @@ class Manager {
371
371
) ,
372
372
} ;
373
373
374
- const buffer = encodeSnapshots ( snapshots ) ;
374
+ const buffer = await encodeSnapshots ( snapshots ) ;
375
375
const reportBuffer = generateReport ( relFile , snapFile , snapshots ) ;
376
376
377
- fs . mkdirSync ( dir , { recursive : true } ) ;
377
+ await fs . promises . mkdir ( dir , { recursive : true } ) ;
378
378
379
379
const temporaryFiles = [ ] ;
380
380
const tmpfileCreated = file => temporaryFiles . push ( file ) ;
381
- writeFileAtomic . sync ( snapPath , buffer , { tmpfileCreated} ) ;
382
- writeFileAtomic . sync ( reportPath , reportBuffer , { tmpfileCreated} ) ;
381
+ await Promise . all ( [
382
+ writeFileAtomic ( snapPath , buffer , { tmpfileCreated} ) ,
383
+ writeFileAtomic ( reportPath , reportBuffer , { tmpfileCreated} ) ,
384
+ ] ) ;
383
385
return {
384
386
changedFiles : [ snapPath , reportPath ] ,
385
387
temporaryFiles,
0 commit comments