caderek / gramma

command-line grammar checker
https://caderek.github.io/gramma/
ISC License
252 stars 18 forks source link

ERR_INVALID_ARG_TYPE when trying to add to local dictionary #39

Open kript opened 2 years ago

kript commented 2 years ago

Describe the bug

When running gramma against a markdown file using en-GB language, a new word is found. Attempting to add it to the dictionary causes an npm error. New files can be created in users home directory and in current working directory.

To Reproduce

gramma check -m -l "en-GB" Lessons.md
Language: English (GB)
Resolved: 0 | Pending: 12
---------------------------------

Rule: typos
Explanation: Possible spelling mistake found.

Context: # Lessons  1. [What is iRODS?](https://github.com/metadata-school/In...
Suggested fix: 1) rods  2) irons  3) iPods  4) prods

---------------------------------
? What do you want to do?
Enter: default (1)
1-4: choose fix
0: custom fix
i: ignore
l: add to local dictionary
g: add to global dictionary
n: next
 › l
node:internal/errors:464
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.openSync (node:fs:577:10)
    at Object.openSync (pkg/prelude/bootstrap.js:739:32)
    at Object.writeFileSync (node:fs:2153:35)
    at configure (/snapshot/gramma/src/actions/configure.js:87:6)
    at checkInteractively (/snapshot/gramma/src/actions/checkInteractively.js:50:7)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async check (/snapshot/gramma/src/commands/check.js:32:31) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Expected behavior

New word is added to the local dictionary.

Desktop (please complete the following information):

kript commented 2 years ago

I have just discovered that this occurs when gramma init has not been run first.