Skip to content

Commit

Permalink
extract shared exe suffix logic
Browse files Browse the repository at this point in the history
Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode committed Nov 7, 2023
1 parent 6abdba0 commit 2ca0d8f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
9 changes: 3 additions & 6 deletions dist/attachReleaseAssets/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions dist/downloadSyft/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions dist/runSyftAction/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions src/github/SyftGithubAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const PRIOR_ARTIFACT_ENV_VAR = "ANCHORE_SBOM_ACTION_PRIOR_ARTIFACT";
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "sbom-action-"));
const githubDependencySnapshotFile = `${tempDir}/github.sbom.json`;

const exeSuffix = process.platform == "win32" ? ".exe" : "";

/**
* Tries to get a unique artifact name or otherwise as appropriate as possible
*/
Expand Down Expand Up @@ -205,18 +207,14 @@ export async function downloadSyft(): Promise<string> {

await execute("sh", [installPath, "-d", "-b", syftBinaryPath, version]);

const installedPath = path.join(`${syftBinaryPath}`, `${name}`);
if (process.platform === "win32") {
return `${installedPath}.exe`;
}
return installedPath;
return path.join(syftBinaryPath, name) + exeSuffix;
}

/**
* Gets the Syft command to run via exec
*/
export async function getSyftCommand(): Promise<string> {
const name = SYFT_BINARY_NAME + (process.platform == "win32" ? ".exe" : "");
const name = SYFT_BINARY_NAME + exeSuffix;
const version = SYFT_VERSION;

const sourceSyft = await downloadSyftFromZip(version);
Expand Down

0 comments on commit 2ca0d8f

Please sign in to comment.