You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by GitBox <gi...@apache.org> on 2022/09/07 20:21:46 UTC

[GitHub] [daffodil-vscode] mbeckerle commented on a diff in pull request #240: Test suite updates

mbeckerle commented on code in PR #240:
URL: https://github.com/apache/daffodil-vscode/pull/240#discussion_r965226820


##########
yarn.lock:
##########
@@ -8,22 +8,22 @@
   integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==

Review Comment:
   I believe yarn.lock should not be part of any commit. Should we add it to .gitignore?



##########
src/utils.ts:
##########
@@ -130,3 +136,90 @@ export function getConfig(
       : defaultConf.get('daffodilDebugClasspath', ''),
   }
 }
+
+export async function unzipFile(zipFilePath: string, extractPath: string) {
+  return await new Promise((resolve, reject) => {
+    let stream = fs
+      .createReadStream(zipFilePath)
+      .pipe(unzip.Extract({ path: `${extractPath}` }))
+    stream.on('close', () => {
+      try {
+        resolve(zipFilePath)
+      } catch (err) {
+        reject(err)
+      }
+    })
+  })
+}
+
+export async function executeScript(
+  name: string,
+  cwd: string,
+  shellPath: string,
+  shellArgs: string[] = []
+) {
+  // Start server in terminal based on scriptName
+  let terminal = vscode.window.createTerminal({
+    name: name,
+    cwd: cwd,
+    hideFromUser: false,
+    shellPath: shellPath,
+    shellArgs: shellArgs,
+  })
+  terminal.show()
+
+  return terminal
+}
+
+export async function killProcess(id: number | undefined) {
+  if (id) {
+    if (os.platform() === 'win32') {
+      child_process.exec(`taskkill /F /PID ${id}`)
+    } else {
+      child_process.exec(`kill -9 ${id} 2>&1 || echo 0`)
+    }
+  }
+}
+
+export async function runScript(
+  scriptPath: string,
+  artifact: Artifact,
+  shellPath: string | null = null,
+  shellArgs: string[] = [],
+  env:
+    | {
+        [key: string]: string | null | undefined
+      }
+    | undefined = undefined,
+  type: string = '',
+  hideTerminal: boolean = false
+) {
+  const delay = (ms: number) => new Promise((res) => setTimeout(res, ms))
+
+  if (!os.platform().toLowerCase().startsWith('win')) {
+    child_process.execSync(
+      `chmod +x ${scriptPath.replace(
+        ' ',
+        '\\ '
+      )}/bin/${artifact.scriptName.replace('./', '')}`
+    )
+  }
+
+  // Start server in terminal based on scriptName
+  let terminal = vscode.window.createTerminal({
+    name: artifact.scriptName,
+    cwd: `${scriptPath}/bin`,
+    hideFromUser: false,
+    shellPath: shellPath !== null ? shellPath : artifact.scriptName,
+    shellArgs: shellArgs,
+    env: env,
+  })
+
+  if (!hideTerminal) terminal.show()
+
+  type.includes('daffodil')
+    ? await delay(5000).then(() => {})
+    : await wait_port({ host: '127.0.0.1', port: 9000, output: 'silent' })
+
+  return terminal
+}

Review Comment:
   They won't let me comment on the next file. yarn.lock should not be checked in. 



##########
src/adapter/activateDaffodilDebug.ts:
##########
@@ -24,6 +24,35 @@ import * as launchWizard from '../launchWizard/launchWizard'
 import * as omegaEditClient from '../omega_edit/client'
 import * as dfdlLang from '../language/dfdl'
 
+// Method to file path for program and data

Review Comment:
   Is there any sort of javadoc-like thing for typescript?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org