Skip to content

Commit

Permalink
Merge pull request #77 from tshino/fix-gen-keymap-wrapper
Browse files Browse the repository at this point in the history
Fix gen_keymap_wrapper.js end with exit code 0 even when it fails
  • Loading branch information
tshino authored Mar 19, 2022
2 parents f5a7c93 + d5c30c9 commit b9ba1f3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to the Keyboard Macro Bata extension will be documented in t
- Updated default keybindings based on VS Code 1.65.2. [#74](https://github.com/tshino/vscode-kb-macro/pull/74)
- Internal
- Added `record` option to the `kb-macro.wrap` command. [#76](https://github.com/tshino/vscode-kb-macro/pull/76)
- Fixed: gen_keymap_wrapper.js end with exit code 0 even when it fails [#77](https://github.com/tshino/vscode-kb-macro/pull/77)

### [0.11.3] - 2022-03-06
- Update
Expand Down
5 changes: 4 additions & 1 deletion generator/gen_keymap_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,7 @@ async function main() {
}
}

main();
main().catch(error => {
genWrapperUtil.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion generator/gen_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ async function main() {
}

main().catch(error => {
console.error(error);
genWrapperUtil.error(error);
process.exit(1);
});
7 changes: 3 additions & 4 deletions generator/gen_wrapper_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const util = require('util');

function error(...msg) {
msg = [ '\u001b[31mError:' ].concat(msg).concat([ '\u001b[0m' ]);
console.log.apply(null, msg);
console.error.apply(null, msg);
}

function warn(...msg) {
msg = [ '\u001b[33mWarning:' ].concat(msg).concat([ '\u001b[0m' ]);
console.log.apply(null, msg);
console.warn.apply(null, msg);
}

async function readJSON(path, options = {}) {
Expand Down Expand Up @@ -196,8 +196,7 @@ function decomposeAwaitOption(awaitOption) {
const awaitList = parseAwaitOption(awaitOption);
const conditionals = awaitList.filter(a => a.condition);
if (1 < conditionals.length) {
error('Using multiple conditional await options is not supported');
throw 'error';
throw 'Using multiple conditional await options is not supported';
} else if (0 < conditionals.length) {
return [
{
Expand Down
12 changes: 12 additions & 0 deletions test/suite/gen_wrapper_util.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ describe('gen_wrapper_util', () => {
];
assert.deepStrictEqual(decomposeAwaitOption(input), expected);
});
it('should throw an error when there are multiple conditions', () => {
const input = '[cond1]await1 [cond2]await2';
assert.throws(
() => {
decomposeAwaitOption(input);
},
err => {
assert.strictEqual(err, 'Using multiple conditional await options is not supported');
return true;
}
);
});
});
describe('makeWrapperWhen', () => {
const makeWrapperWhen = genWrapperUtil.makeWrapperWhen;
Expand Down

0 comments on commit b9ba1f3

Please sign in to comment.