You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by sh...@apache.org on 2022/01/14 23:44:49 UTC

[daffodil-vscode] branch main updated: Update launchWizard so that it will now work with windows.

This is an automated email from the ASF dual-hosted git repository.

shanedell pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c7bcf2  Update launchWizard so that it will now work with windows.
4c7bcf2 is described below

commit 4c7bcf2bf87e9f40b530c587ac9bb623ff0e995f
Author: Shane Dell <sh...@gmail.com>
AuthorDate: Mon Jan 10 13:57:37 2022 -0500

    Update launchWizard so that it will now work with windows.
    
    Closes #67
---
 src/launchWizard/launchWizard.ts | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/src/launchWizard/launchWizard.ts b/src/launchWizard/launchWizard.ts
index d58fc7a..4b8c786 100644
--- a/src/launchWizard/launchWizard.ts
+++ b/src/launchWizard/launchWizard.ts
@@ -18,6 +18,7 @@
 import * as vscode from 'vscode'
 import * as fs from 'fs'
 import { getConfig } from '../utils'
+import * as os from 'os'
 
 const defaultConf = getConfig('Wizard Config', 'launch', 'dfdl')
 
@@ -52,12 +53,15 @@ async function createUpdateConfigFile(data, updateOrCreate) {
     fs.mkdirSync(`${rootPath}/.vscode`)
   }
 
+  const launchPath =
+    os.platform() === 'win32'
+      ? `/${rootPath}/.vscode/launch.json`
+      : `${rootPath}/.vscode/launch.json`
+
   // Create launch.json if it doesn't exist already
   if (!fs.existsSync(`${rootPath}/.vscode/launch.json`)) {
     fs.writeFileSync(`${rootPath}/.vscode/launch.json`, data)
-    vscode.window.showTextDocument(
-      vscode.Uri.parse(`${rootPath}/.vscode/launch.json`)
-    )
+    vscode.window.showTextDocument(vscode.Uri.parse(launchPath))
     return
   }
 
@@ -112,9 +116,7 @@ async function createUpdateConfigFile(data, updateOrCreate) {
     }
   }
 
-  vscode.window.showTextDocument(
-    vscode.Uri.parse(`${rootPath}/.vscode/launch.json`)
-  )
+  vscode.window.showTextDocument(vscode.Uri.parse(launchPath))
 }
 
 // Function to update the config values in the webview panel
@@ -280,10 +282,13 @@ class LaunchWizard {
   getWebViewContent() {
     const scriptUri = vscode.Uri.parse(
       this.ctx.asAbsolutePath('./src/launchWizard/launchWizard.js')
-    ).with({ scheme: 'vscode-resource' })
+    )
     const styleUri = vscode.Uri.parse(
       this.ctx.asAbsolutePath('./src/launchWizard/styles.css')
-    ).with({ scheme: 'vscode-resource' })
+    )
+    const scriptData = fs.readFileSync(scriptUri.fsPath)
+    const styleData = fs.readFileSync(styleUri.fsPath)
+
     const nonce = this.getNonce()
 
     let rootPath = vscode.workspace.workspaceFolders
@@ -359,8 +364,12 @@ class LaunchWizard {
       <title>Launch Config Wizard</title>
     </head>
     <body>
-      <link rel="stylesheet" type="text/css" href="${styleUri}">
-      <script nonce="${nonce}" src="${scriptUri}"></script>
+      <style>
+        ${styleData}
+      </style>
+      <script nonce="${nonce}">
+        ${scriptData}
+      </script>
       <h2 style="color: white;">Daffodil Debugger Config Settings</h2>
 
       <div id="configSelectionDropDown" class="setting-div">