Skip to content

Commit

Permalink
chore: Minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rsenden committed Sep 22, 2023
1 parent 7b786c7 commit 444e8b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions setup/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6602,7 +6602,7 @@ function installAndConfigure(internalFcliCmd, toolName, toolVersion) {
core.info(`Skipping ${toolName} installation`);
}
else {
const installPath = yield installIfNotCached(internalFcliCmd, toolName, toolVersion);
const installPath = yield installIfNotCached(internalFcliCmd, toolName, toolVersion, core.info);
exportVariables(toolName, toolVersion, installPath);
}
});
Expand All @@ -6612,17 +6612,17 @@ function installAndConfigure(internalFcliCmd, toolName, toolVersion) {
* This function doesn't export any variables; this is handled by installAndConfigure
* if applicable.
*/
function installIfNotCached(internalFcliCmd, toolName, toolVersion) {
function installIfNotCached(internalFcliCmd, toolName, toolVersion, log) {
return __awaiter(this, void 0, void 0, function* () {
const installPath = `/opt/fortify/${toolName}/${toolVersion}`;
// We explicitly don't use GitHub tool-cache as we support semantic versioning;
// versions like 'latest' or 'v2' may change over time so we don't want to use
// an older cached version.
// an older cached version in case new versions are released.
if (fs.existsSync(installPath)) {
core.info(`Using previously installed ${toolName} ${toolVersion}`);
log(`Using previously installed ${toolName} ${toolVersion}`);
}
else {
core.info(`Installing ${toolName} ${toolVersion}`);
log(`Installing ${toolName} ${toolVersion}`);
yield install(internalFcliCmd, toolName, toolVersion, installPath);
}
return installPath;
Expand Down Expand Up @@ -6743,9 +6743,9 @@ function getToolVersion(tool) {
function main() {
return __awaiter(this, void 0, void 0, function* () {
try {
// Install fixed fcli version for internal action use by this
// action only.
const internalFcliCmd = core.toPlatformPath((yield installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION)) + '/bin/fcli');
// Install fixed fcli version for internal action use by this action only.
const internalFcliPath = yield installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION, core.debug);
const internalFcliCmd = core.toPlatformPath(`${internalFcliPath}/bin/fcli`);
// Install user-specified tools
const tools = ['fcli', 'sc-client', 'fod-uploader', 'vuln-exporter'];
for (const tool of tools) {
Expand Down
16 changes: 8 additions & 8 deletions setup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function installAndConfigure(internalFcliCmd: string, toolName: string, to
if (toolVersion==='skip') {
core.info(`Skipping ${toolName} installation`);
} else {
const installPath = await installIfNotCached(internalFcliCmd, toolName, toolVersion);
const installPath = await installIfNotCached(internalFcliCmd, toolName, toolVersion, core.info);
exportVariables(toolName, toolVersion, installPath)
}
}
Expand All @@ -26,15 +26,15 @@ async function installAndConfigure(internalFcliCmd: string, toolName: string, to
* This function doesn't export any variables; this is handled by installAndConfigure
* if applicable.
*/
async function installIfNotCached(internalFcliCmd: string, toolName: string, toolVersion: string): Promise<string> {
async function installIfNotCached(internalFcliCmd: string, toolName: string, toolVersion: string, log: (arg: string) => void): Promise<string> {
const installPath = `/opt/fortify/${toolName}/${toolVersion}`;
// We explicitly don't use GitHub tool-cache as we support semantic versioning;
// versions like 'latest' or 'v2' may change over time so we don't want to use
// an older cached version.
// an older cached version in case new versions are released.
if (fs.existsSync(installPath)) {
core.info(`Using previously installed ${toolName} ${toolVersion}`);
log(`Using previously installed ${toolName} ${toolVersion}`);
} else {
core.info(`Installing ${toolName} ${toolVersion}`);
log(`Installing ${toolName} ${toolVersion}`);
await install(internalFcliCmd, toolName, toolVersion, installPath);
}
return installPath;
Expand Down Expand Up @@ -144,9 +144,9 @@ function getToolVersion(tool: string): string {
*/
async function main(): Promise<void> {
try {
// Install fixed fcli version for internal action use by this
// action only.
const internalFcliCmd = core.toPlatformPath(await installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION)+'/bin/fcli');
// Install fixed fcli version for internal action use by this action only.
const internalFcliPath = await installIfNotCached('', 'fcli', INTERNAL_FCLI_VERSION, core.debug);
const internalFcliCmd = core.toPlatformPath(`${internalFcliPath}/bin/fcli`);

// Install user-specified tools
const tools = ['fcli', 'sc-client', 'fod-uploader', 'vuln-exporter']
Expand Down

0 comments on commit 444e8b9

Please sign in to comment.