This is an automated email from the ASF dual-hosted git repository. marat pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push: new 27ff170 Fix vscode extension root folder (#25) 27ff170 is described below commit 27ff170d3890ab39f2f64408b3911c8e8f43b0bf Author: Marat Gubaidullin <marat.gubaidul...@gmail.com> AuthorDate: Thu Oct 14 19:34:35 2021 -0400 Fix vscode extension root folder (#25) --- karavan-vscode/src/extension.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/karavan-vscode/src/extension.ts b/karavan-vscode/src/extension.ts index e9d569c..94c0c3e 100644 --- a/karavan-vscode/src/extension.ts +++ b/karavan-vscode/src/extension.ts @@ -101,10 +101,10 @@ function openKaravanWebView(context: vscode.ExtensionContext, webviewContent: st ); // Read and send Kamelets - panel.webview.postMessage({command: 'kamelets', kamelets: readKamelets()}); + panel.webview.postMessage({command: 'kamelets', kamelets: readKamelets(context)}); // Read and send Components - panel.webview.postMessage({command: 'components', components: readComponents()}); + panel.webview.postMessage({command: 'components', components: readComponents(context)}); // Send integration panel.webview.postMessage({command: 'open', name: name, yaml: yaml}); @@ -130,19 +130,15 @@ function openKaravanWebView(context: vscode.ExtensionContext, webviewContent: st ); } -function readKamelets(): string[] { - const uri: vscode.Uri = vscode.Uri.file(path.resolve( - path.join(__dirname, './kamelets') - )) - const yamls: string[] = fs.readdirSync(uri.fsPath).filter(file => file.endsWith("yaml")).map(file => fs.readFileSync(uri.fsPath + "/" + file, 'utf-8')); +function readKamelets(context: vscode.ExtensionContext): string[] { + const dir = path.join(context.extensionPath, 'kamelets'); + const yamls: string[] = fs.readdirSync(dir).filter(file => file.endsWith("yaml")).map(file => fs.readFileSync(dir + "/" + file, 'utf-8')); return yamls; } -function readComponents(): string[] { - const uri: vscode.Uri = vscode.Uri.file(path.resolve( - path.join(__dirname, './components') - )) - const jsons: string[] = fs.readdirSync(uri.fsPath).filter(file => file.endsWith("json")).map(file => fs.readFileSync(uri.fsPath + "/" + file, 'utf-8')); +function readComponents(context: vscode.ExtensionContext): string[] { + const dir = path.join(context.extensionPath, 'components'); + const jsons: string[] = fs.readdirSync(dir).filter(file => file.endsWith("json")).map(file => fs.readFileSync(dir + "/" + file, 'utf-8')); console.log(jsons) return jsons; }