mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Update main.js code flow so proxy always gets stopped + add comment on why exit status is handled in bin/aikido-(tool).js
This commit is contained in:
parent
ccaa7934ee
commit
3ef4ed8bad
2 changed files with 30 additions and 16 deletions
|
|
@ -16,24 +16,36 @@ export async function main(args) {
|
|||
args = initializeCliArguments(args);
|
||||
|
||||
if (shouldScanCommand(args)) {
|
||||
await scanCommand(args);
|
||||
const resultCode = await scanCommand(args);
|
||||
|
||||
// Returning the exit code back to the caller allows the promise
|
||||
// to be awaited in the bin files and return the correct exit code
|
||||
if (resultCode !== 0) {
|
||||
return resultCode;
|
||||
}
|
||||
}
|
||||
|
||||
var result = await getPackageManager().runCommand(args);
|
||||
|
||||
proxy.verifyNoMaliciousPackages();
|
||||
|
||||
ui.emptyLine();
|
||||
ui.writeInformation(
|
||||
`${chalk.green(
|
||||
"✔"
|
||||
)} Safe-chain: Command completed, no malicious packages found.`
|
||||
);
|
||||
|
||||
// Returning the exit code back to the caller allows the promise
|
||||
// to be awaited in the bin files and return the correct exit code
|
||||
return result.status;
|
||||
} catch (error) {
|
||||
ui.writeError("Failed to check for malicious packages:", error.message);
|
||||
process.exit(1);
|
||||
|
||||
// Returning the exit code back to the caller allows the promise
|
||||
// to be awaited in the bin files and return the correct exit code
|
||||
return 1;
|
||||
} finally {
|
||||
await proxy.stopServer();
|
||||
}
|
||||
|
||||
var result = await getPackageManager().runCommand(args);
|
||||
|
||||
await proxy.stopServer();
|
||||
proxy.verifyNoMaliciousPackages();
|
||||
|
||||
ui.emptyLine();
|
||||
ui.writeInformation(
|
||||
`${chalk.green(
|
||||
"✔"
|
||||
)} Safe-chain: Command completed, no malicious packages found.`
|
||||
);
|
||||
|
||||
return result.status;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue