Skip to content

Commit

Permalink
feat: enable error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
j-sp4 committed Feb 26, 2021
1 parent 108eb76 commit 5f26a44
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
16 changes: 6 additions & 10 deletions src/cli/commands/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ async function test(...args: MethodArgs): Promise<TestCommandResult> {

const ecosystem = getEcosystemForTest(options);
if (ecosystem) {
try {
const commandResult = await testEcosystem(
ecosystem,
args as string[],
options,
);
return commandResult;
} catch (error) {
throw new Error(error);
}
const commandResult = await testEcosystem(
ecosystem,
args as string[],
options,
);
return commandResult;
}

// Promise waterfall to test all other paths sequentially
Expand Down
36 changes: 22 additions & 14 deletions src/lib/plugins/code/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,35 @@ export async function getCodeAnalysisAndParseResults(
root: string,
options: Options,
): Promise<Log> {
let currentLabel = ''
await spinner.clearAll()
codeClient.emitter.on('scanFilesProgress', async(processed: number) => {
const spinnerLbl =`Indexed ${processed} files`;
let currentLabel = '';
await spinner.clearAll();
codeClient.emitter.on('scanFilesProgress', async (processed: number) => {
const spinnerLbl = `Indexed ${processed} files`;
spinner.clear<void>(currentLabel)();
currentLabel = spinnerLbl
currentLabel = spinnerLbl;
await spinner(spinnerLbl);
});
codeClient.emitter.on('uploadBundleProgress', async(processed: number, total: number) => {
const spinnerLbl = `Upload bundle progress: ${processed}/${total}`;
codeClient.emitter.on(
'uploadBundleProgress',
async (processed: number, total: number) => {
const spinnerLbl = `Upload bundle progress: ${processed}/${total}`;
spinner.clear<void>(currentLabel)();
currentLabel = spinnerLbl;
await spinner(spinnerLbl);
},
);
codeClient.emitter.on('analyseProgress', async (data: any) => {
const spinnerLbl = `Analysis ${data.status}: ${Math.round(
data.progress * 100,
)}%`;
spinner.clear<void>(currentLabel)();
currentLabel = spinnerLbl
await spinner(spinnerLbl);
});
codeClient.emitter.on('analyseProgress', async(data: any) => {
const spinnerLbl = `Analysis ${data.status}: ${Math.round(data.progress *100)}%`;
spinner.clear<void>(currentLabel)();
currentLabel = spinnerLbl
currentLabel = spinnerLbl;
await spinner(spinnerLbl);
});

codeClient.emitter.on('sendError', (error) => {
throw error;
});
const codeAnalysis = await getCodeAnalysis(root, options);
spinner.clearAll();
return parseSecurityResults(codeAnalysis);
Expand Down

0 comments on commit 5f26a44

Please sign in to comment.