diff --git a/lib/sync-changes.js b/lib/sync-changes.js index 626a1978c1..4227e4afd7 100644 --- a/lib/sync-changes.js +++ b/lib/sync-changes.js @@ -5,6 +5,7 @@ const EventEmitter = require('events') const browserSync = require('browser-sync') const { ensureDirSync, writeJsonSync } = require('fs-extra') const path = require('path') +const util = require('util') const { tmpDir } = require('./utils/paths') const fs = require('fs') @@ -19,8 +20,15 @@ function hasRestartedAfterError () { } function flagError (error) { + const errorFormatted = util.inspect(error, { + compact: false, + depth: Infinity, + maxArrayLength: Infinity, + maxStringLength: Infinity + }) + ensureDirSync(path.dirname(errorsFile)) - writeJsonSync(errorsFile, { error }) + writeJsonSync(errorsFile, { error: errorFormatted }) } function unflagError () { diff --git a/lib/sync-changes.test.js b/lib/sync-changes.test.js index 3974f55901..574adc5d55 100644 --- a/lib/sync-changes.test.js +++ b/lib/sync-changes.test.js @@ -23,11 +23,12 @@ describe('sync-changes', () => { it('flags error correctly', () => { const error = { data: true } + const errorFormatted = '{\n data: true\n}' syncChanges.flagError(error) expect(fse.writeJsonSync).toHaveBeenCalledTimes(1) - expect(fse.writeJsonSync).toHaveBeenCalledWith(errorsFile, { error }) + expect(fse.writeJsonSync).toHaveBeenCalledWith(errorsFile, { error: errorFormatted }) }) it('syncs correctly', () => {