File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @codebolt/codeboltjs" ,
3
- "version" : " 1.1.66 " ,
3
+ "version" : " 1.1.67 " ,
4
4
"description" : " " ,
5
5
"keywords" : [],
6
6
"author" : " " ,
Original file line number Diff line number Diff line change @@ -64,13 +64,12 @@ const cbfs = {
64
64
* @param {string } filePath - The path of the file to read.
65
65
* @returns {Promise<ReadFileResponse> } A promise that resolves with the server response.
66
66
*/
67
- readFile : ( filename : string , filePath : string ) : Promise < ReadFileResponse > => {
67
+ readFile : ( filePath : string ) : Promise < ReadFileResponse > => {
68
68
return new Promise ( ( resolve , reject ) => {
69
69
cbws . getWebsocket . send ( JSON . stringify ( {
70
70
"type" :"fsEvent" ,
71
71
"action" : "readFile" ,
72
72
"message" : {
73
- filename,
74
73
filePath
75
74
} ,
76
75
} ) ) ;
@@ -233,6 +232,31 @@ const cbfs = {
233
232
} ) ;
234
233
} ) ;
235
234
} ,
235
+ /**
236
+ * @function writeToFile
237
+ * @description Writes content to a file.
238
+ * @param {string } relPath - The relative path of the file to write to.
239
+ * @param {string } newContent - The new content to write into the file.
240
+ * @returns {Promise<{success: boolean, result: any}> } A promise that resolves with the write operation result.
241
+ */
242
+ writeToFile : ( relPath :string , newContent :string ) => {
243
+ return new Promise ( ( resolve , reject ) => {
244
+ cbws . getWebsocket . send ( JSON . stringify ( {
245
+ "type" : "fsEvent" ,
246
+ "action" : "writeToFile" ,
247
+ "message" : {
248
+ relPath,
249
+ newContent
250
+ }
251
+ } ) ) ;
252
+ cbws . getWebsocket . on ( 'message' , ( data :string ) => {
253
+ const response = JSON . parse ( data ) ;
254
+ if ( response . type === "writeToFileResponse" ) {
255
+ resolve ( response ) ;
256
+ }
257
+ } ) ;
258
+ } ) ;
259
+ } ,
236
260
237
261
} ;
238
262
You can’t perform that action at this time.
0 commit comments