Skip to content

Commit 0dce957

Browse files
committed
Fix Save Bug
`result` never populated outside of the await
1 parent bf017ff commit 0dce957

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/commands/lint.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,19 @@ export const handler = async (argv: Arguments<Options>): Promise<void> => {
107107
);
108108

109109
// Run the linter
110-
var result: Array<Object> = [];
111110
await spectral.run(spec).then((result: Array<Object>) => {
112111
if (json) {
113112
// Print result in JSON format so that it can be parsed programmatically
114113
console.log(JSON.stringify(result, null, 2));
115114
} else {
116115
console.log(util.inspect(result, { showHidden: false, depth: null, colors: true }));
117116
}
117+
// save the console output to a .json file in the home directory if -s argument is passed
118+
if (save) {
119+
saveResult(specName + "_lint_result.json", homeDir, result);
120+
}
118121
});
119122

120-
// save the console output to a .json file in the home directory if -s argument is passed
121-
if (save) {
122-
saveResult(specName + "_lint_result.json", homeDir, JSON.stringify(result, null, 4));
123-
}
124-
125123
// If ruleset was downloaded successfully - delete it
126124
if (downloadSuccess) {
127125
deleteRemoteRuleset();

0 commit comments

Comments
 (0)