Closed eladb closed 3 months ago
@Chriscbr - could you please decide the API here?
pub static appendFile(path: string, data: string, options: AppendFileOptions?);
I will appreciate more details here please @Chriscbr & @eladb
@revitalbarletz this is a new method that can be added to the fs
module here: https://github.com/winglang/wing/blob/main/libs/wingsdk/src/fs/fs.ts
It should take a path to a file and insert new data at the end of the file.
For the implementation in JavaScript see also https://stackoverflow.com/questions/3459476/how-to-append-to-a-file-in-node
@eladb I am interested to work on this issue.
You got it @CJLA 👍 Let us know if you have any questions or need some pointers.
@CJLA let us know how it goes and if you need any assistance here!
I am getting this error:
Parsing error: Cannot read file '__dirname/tsconfig.dev.json'
on the first line of https://github.com/winglang/wing/blob/main/libs/wingsdk/src/fs/fs.ts where it is importing the fs module.
The parser and parserOptions in eslintrc.json are currently:
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module",
"project": "./tsconfig.dev.json"
},
I tried adding:
"tsconfigRootDir": "__dirname",
to the parserOptions as suggested here:
https://stackoverflow.com/questions/64933543/parsing-error-cannot-read-file-tsconfig-json-eslint
and here:
https://bobbyhadz.com/blog/typescript-parsing-error-cannot-read-file
but I get this error instead:
'__dirname/tsconfig.dev.json'
This is with the project opened in VSCode (the first time I have cloned the repo and setup the work environment). Any suggestions?
I found existing unit tests in: https://github.com/winglang/wing/blob/main/examples/tests/sdk_tests/fs/basic.test.w
I added a method, appendFile
to the fs
module which calls the fs.appendFile
method. I attempted to write a unit test in the test file, but when I call fs.appendFile
, it doesn't recognize it (unknown symbol, "appendFile").
Hi @CJLA, what command are you using to test the file?
Did you try running pnpm wing test examples/tests/sdk_tests/fs/basic.test.w
at the root directory?
Did you solve the error above?
I am getting this error: Parsing error: Cannot read file '__dirname/tsconfig.dev.json'
@tsuf239 I haven't run the test file because the error is occurring as I type the code. For example, if I add this code to the test:
fs.appendFile(filepath, appendData);
the linter highlights appendFile
and says unknown symbol, "appendFile", even after I have created that method in the
fs` module.
Did you solve the error above?
I am getting this error: Parsing error: Cannot read file '__dirname/tsconfig.dev.json'
No I haven't solved this one yet. I'm hesitant to alter the .eslintrc.json
file if the problem is local to my machine. Also the comments in that file say to edit the .projenrc.ts
file to make modifications and it is not yet apparent what edits to make.
@tsuf239 I haven't run the test file because the error is occurring as I type the code. For example, if I add this code to the test:
fs.appendFile(filepath, appendData);
the linter highlightsappendFile
and saysunknown symbol, "appendFile", even after I have created that method in the
fs` module.
it's ok! the linter is connected to the globally installed wing version, and your changes are on the local version,so they aren't reflected in the linter- you can ignore them for now :)
Did you solve the error above?
I am getting this error: Parsing error: Cannot read file '__dirname/tsconfig.dev.json'
No I haven't solved this one yet. I'm hesitant to alter the
.eslintrc.json
file if the problem is local to my machine. Also the comments in that file say to edit the.projenrc.ts
file to make modifications and it is not yet apparent what edits to make.
Maybe here? https://github.com/winglang/wing/blob/main/libs/wingsdk/.projenrc.ts#L205-L248 or somewhere nearby?
Congrats! :rocket: This was released in Wing 0.59.32.
Use Case
Append to files
Proposed Solution
No response
Implementation Notes
No response
Component
No response
Community Notes