icyflame / cli-cube-timer

Time your solves, without leaving the terminal
https://npmjs.org/package/cli-cube-timer
20 stars 5 forks source link

'no such file' error on first save at LOCAL_FILE_PATH #38

Closed Jan-Ka closed 7 years ago

Jan-Ka commented 7 years ago

When running the application for the first time the user will experience an error like

Error: ENOENT: no such file or directory, open '/home/username/.local/share/cube/times.csv'
    at [stacktrace]

It appears to be a timing issue when creating the folder with mkdirp. The default function is asynchronous, there is a dedicated synchronized version.

mkdirp does not return it's internal promise, because of this it would be probably better to either switch to mkdirp.sync or to create a own version.

Jan-Ka commented 7 years ago

Not sure if mkdirp is the real culprit here, while my observation with it is true I found out that the newest version of file-exists also switched to the same pattern of having an async default function and an sync fallback.

50% sure this is only an issue because I decided to upgrade packages prematurely instead of waiting for #33.

icyflame commented 7 years ago

Your observations are true, we should use the sync version. A stat and a mkdirp should take miniscule time on all modern computers.

This is a change in the API, I think. I should have freezed the versions in the package.json. :slightly_frowning_face:

Anyway, this is the plan I have for now:

  1. Remove the file-exists dependency. Instead use fs.existsSync
  2. Review and merge #41
  3. Freeze versions and publish a release with these freezed versions