Skip to content

Commit f37321b

Browse files
more function added in fs
1 parent ac0d45f commit f37321b

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.65",
3+
"version": "1.1.66",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/modules/fs.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,57 @@ const cbfs = {
182182
});
183183
});
184184
},
185+
/**
186+
* @function listCodeDefinitionNames
187+
* @description Lists all code definition names in a given path.
188+
* @param {string} path - The path to search for code definitions.
189+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the list of code definition names.
190+
*/
191+
listCodeDefinitionNames: (path: string): Promise<{success: boolean, result: any}> => {
192+
return new Promise((resolve, reject) => {
193+
cbws.getWebsocket.send(JSON.stringify({
194+
"type": "fsEvent",
195+
"action": "listCodeDefinitionNames",
196+
"message": {
197+
path
198+
}
199+
}));
200+
cbws.getWebsocket.on('message', (data: string) => {
201+
const response = JSON.parse(data);
202+
if (response.type === "listCodeDefinitionNamesResponse") {
203+
resolve(response);
204+
}
205+
});
206+
});
207+
},
208+
209+
/**
210+
* @function searchFiles
211+
* @description Searches files in a given path using a regex pattern.
212+
* @param {string} path - The path to search within.
213+
* @param {string} regex - The regex pattern to search for.
214+
* @param {string} filePattern - The file pattern to match files.
215+
* @returns {Promise<{success: boolean, result: any}>} A promise that resolves with the search results.
216+
*/
217+
searchFiles: (path: string, regex: string, filePattern: string): Promise<{success: boolean, result: any}> => {
218+
return new Promise((resolve, reject) => {
219+
cbws.getWebsocket.send(JSON.stringify({
220+
"type": "fsEvent",
221+
"action": "searchFiles",
222+
"message": {
223+
path,
224+
regex,
225+
filePattern
226+
}
227+
}));
228+
cbws.getWebsocket.on('message', (data: string) => {
229+
const response = JSON.parse(data);
230+
if (response.type === "searchFilesResponse") {
231+
resolve(response);
232+
}
233+
});
234+
});
235+
},
185236

186237
};
187238

0 commit comments

Comments
 (0)