UNPKG

669 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3/**
4 * ensures that a dxcli command or hook exits
5 *
6 * @param code - expected code
7 * @default 0
8 */
9exports.default = (code = 0) => ({
10 run() {
11 throw new Error(`Expected hook to exit with code ${code} but it ran without exiting`);
12 },
13 catch(ctx) {
14 const err = ctx.error;
15 if (!err['cli-ux'] || typeof err['cli-ux'].exit !== 'number')
16 throw err;
17 if (err['cli-ux'].exit !== code) {
18 throw new Error(`Expected hook to exit with ${code} but exited with ${err['cli-ux'].exit}`);
19 }
20 }
21});
22//# sourceMappingURL=exit.js.map
\No newline at end of file