Open AlexCannonball opened 1 month ago
Hi! While I love your detailed issue report, when looking for suggestions, it's important that you provide snippets of code.
Additionally, StackOverflow is also a valuable for code suggestions.
@RedYetiDev Hi and thank you for the reply! I've updated the issue with TypeScript code snippets.
Thanks!
Create the necessary temp directories. Create the temp file. Remove the temporary file and directories after linting is done.
I'm not an expert on code-golfing, so I can't help to much from here, but now oncomers will know what to help with. If you want a faster answer, there's plenty of Code-Golfing communities :-)
Node.js Version
v18.19.1
NPM Version
10.8.0
Operating System
Windows 10 Pro
Subsystem
child_process, fs, Other
Description
Hello,
I make a VS Code extension (Electron/Node.js application) that uses a Golang linter application to lint files. The linter is a third party executable that accepts only paths to files. It also has a configuration YAML where a path to directory or file is used to enable/disable linting rules for particular files:
The VS Code extension should work on Windows, Linux and OS X.
I'd like to make "lint on type" feature in the VS Code extension, conveying unsaved edited text from IDE to the abovementioned linter. I have to create a temporary file with the current IDE text to give it to the linter.
Because of the configuration YAML the relative path of the temporary file should be equal to the original file.
I've successfully made a prototype via
fs.writeFile
to create the temporary file andcp.spawn
to run the linter.However, in this prototype every IDE text edit causes several excessive disk operations:
I have looked for a workaround to reduce/exclude writing to disk, but haven't find one.
IPC from
net
(Windows named pipes and Unix domain socket) doesn't work. The code snippet for Windows is below:cp.spawn
the linter using the named pipe ascwd
, so the linter settings from YAML config are not applied properly. Attempting to use the named pipe ascwd
forcp.spawn
causesENOENT
error.fs.writeFile
withUV_FS_O_FILEMAP
doesn't exclude writing the temporary directories/file to disk.I haven't find a way to create a temporary file with FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE flags on Windows via Node.js.
I guess a minimum program is finding a workaround for Windows, because on Linux and OS X it's easier to create tmpfs and set it for the extension's temp files.
Any ideas, how to make it? Thank you.
Minimal Reproduction
No response
Output
No response
Before You Submit