Skip to content

Commit

Permalink
Fix errors.json logging ENOENT: no such file or directory
Browse files Browse the repository at this point in the history
It was possible for `flagError()` to run before the .tmp directory had been created
  • Loading branch information
colinrotherham committed Sep 13, 2023
1 parent 86fb72a commit 4a65a98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/sync-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const EventEmitter = require('events')

// npm dependencies
const browserSync = require('browser-sync')
const { writeJsonSync } = require('fs-extra')
const { ensureDirSync, writeJsonSync } = require('fs-extra')
const path = require('path')
const { tmpDir } = require('./utils/paths')
const fs = require('fs')
Expand All @@ -19,7 +19,8 @@ function hasRestartedAfterError () {
}

function flagError (error) {
writeJsonSync(path.join(tmpDir, 'errors.json'), { error })
ensureDirSync(path.dirname(errorsFile))
writeJsonSync(errorsFile, { error })
}

function unflagError () {
Expand Down

0 comments on commit 4a65a98

Please sign in to comment.