Skip to content

Commit

Permalink
fix: update bin/dev|run exec for when run.js exist
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Oct 27, 2023
1 parent 0f0447a commit d387c30
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 8 deletions.
63 changes: 60 additions & 3 deletions SAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ describe('execCmd', () => {

```typescript
import { execCmd } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('execCmd', () => {
// This would actually be set in the shell or CI environment.
Expand Down Expand Up @@ -168,6 +174,12 @@ A TestSession provides conveniences to testing plugin commands with options to a

```typescript
import { execCmd, TestSession, TestProject } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand Down Expand Up @@ -196,6 +208,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession, TestProject } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand Down Expand Up @@ -282,6 +300,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand All @@ -306,7 +330,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';

/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { tmpdir } from 'os';
import { expect } from 'chai';

Expand Down Expand Up @@ -388,6 +417,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand Down Expand Up @@ -418,6 +453,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession, TestProject } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand Down Expand Up @@ -450,6 +491,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession, TestProject } from '@salesforce/cli-plugins-testkit';
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

describe('TestSession', () => {
let testSession: TestSession;
Expand Down Expand Up @@ -480,7 +527,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession, TestProject } from '@salesforce/cli-plugins-testkit';

/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as path from 'path';

describe('TestSession', () => {
Expand Down Expand Up @@ -521,7 +573,12 @@ describe('TestSession', () => {

```typescript
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit';

/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import * as shelljs from 'shelljs';

/*
Expand Down
16 changes: 11 additions & 5 deletions src/testSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,17 @@ export class TestSession<T extends TestSessionOptions = TestSessionOptions> exte
// 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')) {
const binDev = path.join(process.cwd(), 'bin', 'dev');
env.setString(
'TESTKIT_EXECUTABLE_PATH',
fs.existsSync(binDev) ? binDev : path.join(process.cwd(), 'bin', 'run')
);
let binDev = path.join(process.cwd(), 'bin', 'dev');
if (!fs.existsSync(binDev)) {
binDev += '.js';
}

// only used in the case when bin/run or bin/run.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);
}

this.stubCwd(projectDir);
Expand Down

0 comments on commit d387c30

Please sign in to comment.