refactor(developer): eliminate `CompilerCallbacks.fs` and `CompilerCallbacks.path`
- Dominant language
- Pascal
- Stars
- 534
- Forks
- 143
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 113
Description
The `CompilerCallbacks.fs` and `CompilerCallbacks.path` members were added as a stepping stone patch to make it easy to get the compilers completed. Now that the compilers are functionally complete, we should go back and remove these, and implement the required functions as top-level callback functions.
# fs
The `fs` members used are:
* `writeFileSync` (multiple locations, all in `KeymanCompiler.write` implementations). `writeFileSync` should be perhaps extracted to a parameter for `KeymanCompiler.write`, as it must only be used there.
* `existsSync` (multiple locations)
These two are used only in `KeymanDeveloperProject.populateFiles()`:
* `readdirSync`: so let's just think about passing the list of files as a parameter here
* `readFileSync`: `CompilerCallbacks.loadFile` already exists, so use that instead (side note: we should rename `loadFile` to `readFile` for consistency)
# path
The `path` members used are:
* `basename` (many places)
* `dirname` (many places)
* `join` (many places)
* `normalize` (kpj loader only, in common/web/types)
* `isAbsolute` (kmc-package only, for a compiler warning)
* `extname` (kmc-package only)
Suggested resolution for `path` is a reimplementation (or copy) of the required functions, because they are relatively straightforward, possibly starting with https://github.com/browserify/path-browserify/blob/master/index.js and https://github.com/nodejs/node/blob/main/lib/path.js, and where possible (e.g. extname) just using regex as we do elsewhere.
Contributor guide
Assessment
This issue has not been assessed yet.