ava 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/runner.js +2 -2
- package/lib/snapshot-manager.js +9 -7
- package/lib/worker/base.js +1 -1
- package/package.json +1 -1
package/lib/runner.js
CHANGED
|
@@ -224,8 +224,8 @@ export default class Runner extends Emittery {
|
|
|
224
224
|
return this.snapshots.skipSnapshot(options);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
saveSnapshotState() {
|
|
228
|
-
return {touchedFiles: this.snapshots.save()};
|
|
227
|
+
async saveSnapshotState() {
|
|
228
|
+
return {touchedFiles: await this.snapshots.save()};
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
onRun(runnable) {
|
package/lib/snapshot-manager.js
CHANGED
|
@@ -182,8 +182,8 @@ function sortBlocks(blocksByTitle, blockIndices) {
|
|
|
182
182
|
);
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
function encodeSnapshots(snapshotData) {
|
|
186
|
-
const encoded = cbor.
|
|
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.
|
|
377
|
+
await fs.promises.mkdir(dir, {recursive: true});
|
|
378
378
|
|
|
379
379
|
const temporaryFiles = [];
|
|
380
380
|
const tmpfileCreated = file => temporaryFiles.push(file);
|
|
381
|
-
|
|
382
|
-
|
|
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,
|
package/lib/worker/base.js
CHANGED
|
@@ -81,7 +81,7 @@ const run = async options => {
|
|
|
81
81
|
|
|
82
82
|
runner.on('finish', async () => {
|
|
83
83
|
try {
|
|
84
|
-
const {touchedFiles} = runner.saveSnapshotState();
|
|
84
|
+
const {touchedFiles} = await runner.saveSnapshotState();
|
|
85
85
|
if (touchedFiles) {
|
|
86
86
|
channel.send({type: 'touched-files', files: touchedFiles});
|
|
87
87
|
}
|