Nixinova / LinguistJS

Analyse and list all languages used in a folder. Implementation of and powered by GitHub's Linguist.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`no such file or directory, lstat` between `analyze()` calls if directory changes

kachkaev opened this issue Β· comments

πŸ‘‹ again @Nixinova πŸ˜…

Here is another small bug πŸ™‚ As I’ve mentioned in #3, I work with two folders: my-analytics-tool and my-analytics-tool-data. The second folder contains the repo I want to analyse.

To create a time series with historic changes in the number of files, I do the following:

  1. Clone a repo into my-analytics-tool-data
  2. List commits in my-analytics-tool-data
  3. Checkout commit x
  4. Run linguist
  5. Save a JSON summary for commit x
  6. Pick another commit and continue from step 3.

So I’ve got a single script which calls analyze("/path/to/my-analytics-tool-data") multiple times. The contents of the analysed folder changes between the calls. When this happens, the function throws with the following message:

Error: ENOENT: no such file or directory, lstat '/path/to/my-analytics-tool-data/path/to/deleted/file.ext'
    at Object.lstatSync (fs.js:1115:3)
    at Object.analyse (/path/to/my-analytics-tool/node_modules/linguist-js/dist/index.js:106:26)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  errno: -2,
  syscall: 'lstat',
  code: 'ENOENT',
  path: '/path/to/my-analytics-tool-data/path/to/deleted/file.ext'
}

It’d be great to have an option to reset cache before running analyze or just make it default behaviour.

Regardless of this small glitch, thanks a lot for your effort! I’ve been waiting for this port for years 😁 πŸ‘πŸ‘πŸ‘πŸ‘

I'll see if I can trap that error, thanks for reporting, and glad to be of help with this port.

Should be fixed in v2.0.2.

Repro folder

No more crashing in v2.0.2 πŸŽ‰