Skip to content

Commit

Permalink
fix: change working directory prior to loading the engine (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-w authored Nov 6, 2022
1 parent d8b17ac commit 6e5bf38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/src/test/runTests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as path from 'path'
import * as fs from 'fs'
import { tmpdir } from 'os'
import { exec } from 'child_process'
import { runTests } from '@vscode/test-electron'

Expand Down Expand Up @@ -43,6 +44,7 @@ async function main (): Promise<void> {
)
process.chdir(testWorkspace)
await execShellCommand('npm install')
process.chdir(tmpdir())
await runTests({
version: 'stable',
extensionDevelopmentPath,
Expand Down
7 changes: 7 additions & 0 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,15 @@ async function resolveSettings (
async path => {
let library = path2Library.get(path)
if (library == null) {
// Need to load the library dynamically, making sure CWD is temporarily
// set to the target workspace
const oldCwd = process.cwd()
if (settings.workspaceFolder != null) {
process.chdir(settings.workspaceFolder.uri.fsPath)
}
// eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
library = (await Function(`return import('file://${path.replace(/\\/g, '\\\\')}')`)()).default
process.chdir(oldCwd)
if (library?.lintText == null) {
settings.validate = false
connection.console.error(
Expand Down

0 comments on commit 6e5bf38

Please sign in to comment.