diff --git a/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 b/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 deleted file mode 160000 index 84dfbfdd..00000000 --- a/test/opentofu-basic/.terraform/modules/test-js-commonjs_3 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 84dfbfddf9483bc56afa0aff516177c03652f0c7 diff --git a/test/utils/getDebuggerStartCommand.ts b/test/utils/getDebuggerStartCommand.ts new file mode 100644 index 00000000..9cfb0bfe --- /dev/null +++ b/test/utils/getDebuggerStartCommand.ts @@ -0,0 +1,33 @@ +export function getDebuggerStartCommand(folder: string, args: string[]) { + let testMonorepo = process.env.TEST_MONOREPO === 'true'; + if (testMonorepo) { + testMonorepo = true; + // just the last two part of the folder + const folderParts = folder.split('/'); + const testProjectFolder = + folderParts[folderParts.length - 2] + + '/' + + folderParts[folderParts.length - 1]; + args.push(`-m ${testProjectFolder}`); + } + + if (process.env.OBSERVABLE_MODE === 'true') { + args.push('-o'); + } + + args.push('-v'); + + let command: string; + + if (process.env.REAL_NPM === 'true') { + console.log('Running the debugger with the real NPM'); + command = `lld ${args?.join(' ')}`; + } else { + command = `node ${testMonorepo ? '' : '../../'}dist/lldebugger.mjs ${args?.join(' ')}`; + console.log('Running the debugger with just genereted code'); + } + console.log(`Command to run LLD: ${command}`); + console.log(`Current folder: ${import.meta.dirname}`); + + return command; +} diff --git a/test/utils/removeInfra.ts b/test/utils/removeInfra.ts index 29c61145..da12b399 100644 --- a/test/utils/removeInfra.ts +++ b/test/utils/removeInfra.ts @@ -1,5 +1,6 @@ import { ChildProcess, execSync } from 'child_process'; import { setTimeout } from 'timers/promises'; +import { getDebuggerStartCommand } from './getDebuggerStartCommand.js'; export async function removeInfra( lldProcess: ChildProcess | undefined, @@ -8,11 +9,7 @@ export async function removeInfra( ) { lldProcess?.kill(); - let command = `node ../../dist/lldebugger.mjs --remove ${args?.join(' ')}`; - - if (process.env.REAL_NPM === 'true') { - command = `lld --remove ${args?.join(' ')}`; - } + const command = getDebuggerStartCommand(folder, [...args, '--remove']); await execSync(command, { cwd: folder, diff --git a/test/utils/startDebugger.ts b/test/utils/startDebugger.ts index d4a1dffd..8feef6c7 100644 --- a/test/utils/startDebugger.ts +++ b/test/utils/startDebugger.ts @@ -2,6 +2,7 @@ import { spawn } from 'child_process'; import { setTimeout } from 'timers/promises'; import { exec } from 'child_process'; import { promisify } from 'util'; +import { getDebuggerStartCommand } from './getDebuggerStartCommand.js'; export const execAsync = promisify(exec); @@ -18,34 +19,8 @@ export async function startDebugger(folder: string, args: string[] = []) { async function startDebuggerInternal(folder: string, args: string[] = []) { console.log('Starting LLD...'); - let testMonorepo = false; - if (process.env.TEST_MONOREPO === 'true') { - testMonorepo = true; - // just the last two part of the folder - const folderParts = folder.split('/'); - const testProjectFolder = - folderParts[folderParts.length - 2] + - '/' + - folderParts[folderParts.length - 1]; - args.push(`-m ${testProjectFolder}`); - } - - if (process.env.OBSERVABLE_MODE === 'true') { - args.push('-o'); - } - - args.push('-v'); - - let command = `node ${ - testMonorepo ? '' : '../../' - }dist/lldebugger.mjs ${args?.join(' ')}`; - - if (process.env.REAL_NPM === 'true') { - console.log('Running the debugger with the real NPM'); - command = `lld ${args?.join(' ')}`; - } else { - console.log('Running the debugger with just genereted code'); - } + const testMonorepo = process.env.TEST_MONOREPO === 'true'; + const command = getDebuggerStartCommand(folder, args); const lldProcess = spawn(command, { cwd: !testMonorepo ? folder : undefined,