Skip to content

Commit

Permalink
Fix intended output
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck committed Jan 22, 2025
1 parent fe24228 commit 9086785
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,4 @@ jobs:
with:
api-key: ${{secrets.fossaApiKey}}
generate-report: json

- run: echo ${{ steps.example-generate-report.outputs.report }}
- run: echo '${{ steps.example-generate-report.outputs.report }}'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
api-key: ${{secrets.fossaApiKey}}
run-tests: true
generate-report: html
- run: ${{ steps.fossa.outputs.report }} > report.html
- run: echo '${{ steps.fossa.outputs.report }}' > report.html
```

## `test-diff-revision`
Expand Down
20 changes: 12 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,32 @@ export async function report(): Promise<void> {
].filter(arg => arg);

// Setup listeners
let output;
const collectOutput = (data: Buffer) => {
output += data.toString();
let stdout;
let stderr;
const collectStdout = (data: Buffer) => {
stdout += data.toString();
};
const collectStderr = (data: Buffer) => {
stdout += data.toString();
};

const listeners: ExecListeners = {
stdout: collectOutput,
stderr: collectOutput,
stdout: collectStdout,
stderr: collectStderr,
};

// Collect default options: Env and listeners
const PATH = process.env.PATH || '';
const defaultOptions = { env: { ...process.env, PATH, FOSSA_API_KEY }, listeners };
output = '';
stdout = '';
const exitCode = await exec('fossa', getArgs(['report', 'attribution']), defaultOptions);

// Check output or exitCode
if (exitCode !== 0 || output.match(failedRegex)) {
if (exitCode !== 0 || stderr.match(failedRegex)) {
throw new Error(`FOSSA failed to scan`);
}

setOutput('report', output);
setOutput('report', stdout);
}

async function run() {
Expand Down

0 comments on commit 9086785

Please sign in to comment.