Skip to content

Commit 06e20f1

Browse files
authored
feat: remove --output flag
1 parent ae23fed commit 06e20f1

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ The 3 commit messages above will be parsed to retrieve all test classes found us
2828
AccountTriggerHandlerTest OpportunityTriggerHandlerTest PrepareMySandboxTest QuoteControllerTest
2929
```
3030

31-
This plugin will also save its output to a text file, `runTests.txt` by default unless you provide a different file path via the `--output` flag.
31+
The command's output is designed to be used with the Salesforce CLI (`sf`) deployment command. So when you want to deploy or validate Apex metadata, you can wrap this command with the deploy command to dynamically build the list of specified tests:
3232

33-
You could then save the contents of this text file to a variable and use that variable in the `sf project deploy` command:
3433

3534
```
36-
sf apex-tests-git-delta delta --from "c7603c25581afe7c443c57e687f2d6abd654ea77" --to "HEAD" --output "runTests.txt"
37-
testclasses=$(<runTests.txt)
38-
sf project deploy start -x package/package.xml -l RunSpecifiedTests -t $testclasses
35+
sf project deploy start -x package/package.xml -l RunSpecifiedTests -t $(sf apex-tests-git-delta delta --from "HEAD~1" --to "HEAD")
3936
```
4037

4138
**NOTE:** The test classes will only be added to the output if they are found in one of your package directories as listed in the `sfdx-project.json` in the `--to` commit's file-tree. If the test class name was not found in any package directory, a warning will be printed to the terminal. The plugin will not fail if no test classes are included in the final output. The output and text file will simply be empty if no delta test classes were found in any commit message or no test classes were validated against a package directory.
@@ -68,12 +65,11 @@ This command will determine the root folder of the repo and look for the `sfdx-p
6865

6966
```
7067
USAGE
71-
$ sf apex-tests-git-delta delta -f <value> -t <value> --output <value> [--json]
68+
$ sf apex-tests-git-delta delta -f <value> -t <value> [--json]
7269
7370
FLAGS
7471
-f, --from=<value> Commit SHA from where the commit message log is done. This SHA's commit message will not be included in the results.
7572
-t, --to=<value> [default: HEAD] Commit SHA to where the commit message log is done.
76-
--output=<value> [default: runTests.txt] The text file to save the delta test classes to.
7773
7874
GLOBAL FLAGS
7975
--json Format output as json.
@@ -82,5 +78,5 @@ DESCRIPTION
8278
Given 2 git commits, this plugin will parse all of the commit messages between this range and return the delta Apex test class string. This can be used to execute delta deployments.
8379
8480
EXAMPLES
85-
$ sf apex-tests-git-delta delta --from "c7603c255" --to "HEAD" --output "runTests.txt"
81+
$ sf apex-tests-git-delta delta --from "HEAD~1" --to "HEAD"
8682
```

messages/delta.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Given 2 git commits, this plugin will parse all of the commit messages between t
88

99
# examples
1010

11-
- `sf apex-tests-git-delta delta --from "c7603c255" --to "HEAD" --output "runTests.txt"`
11+
- `sf apex-tests-git-delta delta --from "HEAD~1" --to "HEAD"`
1212

1313
# flags.from.summary
1414

@@ -17,7 +17,3 @@ Commit SHA from where the commit message log is done. This SHA's commit message
1717
# flags.to.summary
1818

1919
Commit SHA to where the commit message log is done.
20-
21-
# flags.output.summary
22-
23-
The text file to save the delta test classes to.

src/commands/apex-tests-git-delta/delta.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
import { writeFile } from 'node:fs/promises';
4-
53
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
64
import { Messages } from '@salesforce/core';
75
import { extractTestClasses } from '../../service/extractTestClasses.js';
@@ -31,24 +29,16 @@ export default class ApexTestDelta extends SfCommand<TestDeltaResult> {
3129
summary: messages.getMessage('flags.from.summary'),
3230
required: true,
3331
}),
34-
output: Flags.file({
35-
summary: messages.getMessage('flags.output.summary'),
36-
required: true,
37-
exists: false,
38-
default: 'runTests.txt',
39-
}),
4032
};
4133

4234
public async run(): Promise<TestDeltaResult> {
4335
const { flags } = await this.parse(ApexTestDelta);
4436
const toGitRef = flags['to'];
4537
const fromGitRef = flags['from'];
46-
const output = flags['output'];
4738

4839
const result = await extractTestClasses(fromGitRef, toGitRef);
4940
const tests = result.validatedClasses;
5041
const warnings = result.warnings;
51-
await writeFile(output, tests);
5242
if (warnings.length > 0) {
5343
warnings.forEach((warning) => {
5444
this.warn(warning);

0 commit comments

Comments
 (0)