Skip to content

Commit

Permalink
feat: use bin/run
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 30, 2023
1 parent e873274 commit 2bcd7f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/execCmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const getExitCodeError = (cmd: string, expectedCode: number, output: ShellString
*
* If the cli is 'inherit', the executable preference order is:
* 1. TESTKIT_EXECUTABLE_PATH env var
* 2. `bin/dev.js` (default)
* 2. `bin/run.js` (default)
*
* @returns The command string with CLI executable. E.g., `"node_modules/bin/sf org:create:user -a testuser1"`
*/
Expand All @@ -124,11 +124,11 @@ const determineExecutable = (cli: CLI = 'inherit'): string => {
let bin =
cli === 'inherit'
? env.getString('TESTKIT_EXECUTABLE_PATH') ??
pathJoin(process.cwd(), 'bin', process.platform === 'win32' ? 'dev.cmd' : 'dev.js')
pathJoin(process.cwd(), 'bin', process.platform === 'win32' ? 'run.cmd' : 'run.js')
: cli;

// Support plugins who still use bin/dev instead of bin/dev.js
if (bin.endsWith('dev.js') && !fs.existsSync(bin)) bin = bin.replace('.js', '');
// Support plugins who still use bin/run instead of bin/run.js
if (bin.endsWith('run.js') && !fs.existsSync(bin)) bin = bin.replace('.js', '');
const which = shelljs.which(bin);
let resolvedPath = pathResolve(bin);

Expand Down
10 changes: 2 additions & 8 deletions src/testSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,16 @@ export class TestSession<T extends TestSessionOptions = TestSessionOptions> exte
projectDir = this.project.dir;
}

// The default bin/dev in execCmd will no longer resolve properly when
// The default bin/run in execCmd will no longer resolve properly when
// a test project is used since process.cwd is changed. If the
// TESTKIT_EXECUTABLE_PATH env var is not being used, then set it
// to use the bin/dev from the cwd now.
if (!env.getString('TESTKIT_EXECUTABLE_PATH')) {
let binDev = path.join(process.cwd(), 'bin', 'dev');
if (!fs.existsSync(binDev)) {
binDev += '.js';
}

// only used in the case when bin/dev or bin/dev.js doesn't exist
let binRun = path.join(process.cwd(), 'bin', 'run');
if (!fs.existsSync(binRun)) {
binRun += '.js';
}
env.setString('TESTKIT_EXECUTABLE_PATH', fs.existsSync(binDev) ? binDev : binRun);
env.setString('TESTKIT_EXECUTABLE_PATH', binRun);
}

this.stubCwd(projectDir);
Expand Down

0 comments on commit 2bcd7f8

Please sign in to comment.