alphagov / govuk-prototype-kit

Rapidly create HTML prototypes of GOV.UK services
https://prototype-kit.service.gov.uk
MIT License
301 stars 236 forks source link

Fix errors.json logging `ENOENT: no such file or directory` #2332

Closed colinrotherham closed 12 months ago

colinrotherham commented 1 year ago

This PR helped me find and fix an issue in https://github.com/alphagov/govuk-prototype-kit/pull/2306

Before that I was stuck with this error in the terminal:

Error: ENOENT: no such file or directory, open '/private/var/folders/2k/ws6lqbf57d75yf8xt7tt_bqc0000gn/T/test-prototype/.tmp/errors.json'

My issue had crashed early enough to confirm:

  1. The helper flagError() can run before .tmp directory exists
  2. Errors can be written as empty strings by writeJsonSync(errorPath, { error })

This PR stops that from happening