@oclif/test 3.2.14 → 4.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +23 -116
- package/lib/index.js +102 -49
- package/package.json +11 -7
- package/lib/command.d.ts +0 -11
- package/lib/command.js +0 -27
- package/lib/exit.d.ts +0 -11
- package/lib/exit.js +0 -18
- package/lib/hook.d.ts +0 -22
- package/lib/hook.js +0 -24
- package/lib/load-config.d.ts +0 -18
- package/lib/load-config.js +0 -21
package/lib/index.d.ts
CHANGED
|
@@ -1,117 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
output: unknown;
|
|
12
|
-
args: [];
|
|
13
|
-
};
|
|
14
|
-
} & {
|
|
15
|
-
retries: {
|
|
16
|
-
output: unknown;
|
|
17
|
-
args: any[];
|
|
18
|
-
};
|
|
19
|
-
} & {
|
|
20
|
-
catch: {
|
|
21
|
-
output: {
|
|
22
|
-
error: Error;
|
|
23
|
-
};
|
|
24
|
-
args: [arg: string | RegExp | ((err: Error) => any), opts?: {
|
|
25
|
-
raiseIfNotThrown?: boolean | undefined;
|
|
26
|
-
} | undefined];
|
|
27
|
-
};
|
|
28
|
-
} & {
|
|
29
|
-
env: {
|
|
30
|
-
output: unknown;
|
|
31
|
-
args: [env: {
|
|
32
|
-
[k: string]: string | null | undefined;
|
|
33
|
-
}, opts?: fancyTest.FancyTypes.EnvOptions | undefined];
|
|
34
|
-
};
|
|
35
|
-
} & {
|
|
36
|
-
stub: {
|
|
37
|
-
output: {
|
|
38
|
-
sandbox: import("sinon").SinonSandbox;
|
|
39
|
-
};
|
|
40
|
-
args: [object: any, path: any, fn: (stub: import("sinon").SinonStub<any[], any>) => import("sinon").SinonStub<any[], any>];
|
|
41
|
-
};
|
|
42
|
-
} & {
|
|
43
|
-
stdin: {
|
|
44
|
-
output: unknown;
|
|
45
|
-
args: [input: string, delay?: number | undefined];
|
|
46
|
-
};
|
|
47
|
-
} & {
|
|
48
|
-
stderr: {
|
|
49
|
-
output: {
|
|
50
|
-
readonly stderr: string;
|
|
51
|
-
};
|
|
52
|
-
args: [opts?: {
|
|
53
|
-
print?: boolean | undefined;
|
|
54
|
-
stripColor?: boolean | undefined;
|
|
55
|
-
} | undefined];
|
|
56
|
-
};
|
|
57
|
-
} & {
|
|
58
|
-
stdout: {
|
|
59
|
-
output: {
|
|
60
|
-
readonly stdout: string;
|
|
61
|
-
};
|
|
62
|
-
args: [opts?: {
|
|
63
|
-
print?: boolean | undefined;
|
|
64
|
-
stripColor?: boolean | undefined;
|
|
65
|
-
} | undefined];
|
|
66
|
-
};
|
|
67
|
-
} & {
|
|
68
|
-
nock: {
|
|
69
|
-
output: {
|
|
70
|
-
nock: number;
|
|
71
|
-
};
|
|
72
|
-
args: [host: string, options: fancyTest.FancyTypes.NockOptions | fancyTest.FancyTypes.NockCallback, cb?: fancyTest.FancyTypes.NockCallback | undefined];
|
|
73
|
-
};
|
|
74
|
-
} & {
|
|
75
|
-
timeout: {
|
|
76
|
-
output: {
|
|
77
|
-
timeout: number;
|
|
78
|
-
};
|
|
79
|
-
args: [timeout?: number | undefined];
|
|
80
|
-
};
|
|
81
|
-
} & {
|
|
82
|
-
loadConfig: {
|
|
83
|
-
output: {
|
|
84
|
-
config: import("@oclif/core/lib/interfaces").Config;
|
|
85
|
-
};
|
|
86
|
-
args: [opts?: loadConfig.Options | undefined];
|
|
87
|
-
};
|
|
88
|
-
} & {
|
|
89
|
-
command: {
|
|
90
|
-
output: {
|
|
91
|
-
config: import("@oclif/core/lib/interfaces").Config;
|
|
92
|
-
expectation: string;
|
|
93
|
-
returned: unknown;
|
|
94
|
-
};
|
|
95
|
-
args: [args: string | string[], opts?: loadConfig.Options | undefined];
|
|
96
|
-
};
|
|
97
|
-
} & {
|
|
98
|
-
exit: {
|
|
99
|
-
output: {
|
|
100
|
-
error: import("@oclif/core/lib/errors").CLIError;
|
|
101
|
-
};
|
|
102
|
-
args: [code?: number | undefined];
|
|
103
|
-
};
|
|
104
|
-
} & {
|
|
105
|
-
hook: {
|
|
106
|
-
output: {
|
|
107
|
-
config: import("@oclif/core/lib/interfaces").Config;
|
|
108
|
-
expectation: string;
|
|
109
|
-
returned: unknown;
|
|
110
|
-
};
|
|
111
|
-
args: [event: string, hookOpts?: Record<string, unknown> | undefined, options?: loadConfig.Options | undefined];
|
|
112
|
-
};
|
|
1
|
+
import { Errors, Interfaces } from '@oclif/core';
|
|
2
|
+
type CaptureOptions = {
|
|
3
|
+
print?: boolean;
|
|
4
|
+
stripAnsi?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function captureOutput<T>(fn: () => Promise<unknown>, opts?: CaptureOptions): Promise<{
|
|
7
|
+
error?: Error & Partial<Errors.CLIError>;
|
|
8
|
+
result?: T;
|
|
9
|
+
stderr: string;
|
|
10
|
+
stdout: string;
|
|
113
11
|
}>;
|
|
114
|
-
export
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
12
|
+
export declare function runCommand<T>(args: string | string[], loadOpts?: Interfaces.LoadOptions, captureOpts?: CaptureOptions): Promise<{
|
|
13
|
+
error?: Error & Partial<Errors.CLIError>;
|
|
14
|
+
result?: T;
|
|
15
|
+
stderr: string;
|
|
16
|
+
stdout: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function runHook<T>(hook: string, options: Record<string, unknown>, loadOpts?: Interfaces.LoadOptions, recordOpts?: CaptureOptions): Promise<{
|
|
19
|
+
error?: Error & Partial<Errors.CLIError>;
|
|
20
|
+
result?: T;
|
|
21
|
+
stderr: string;
|
|
22
|
+
stdout: string;
|
|
23
|
+
}>;
|
|
24
|
+
export {};
|
package/lib/index.js
CHANGED
|
@@ -1,38 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const
|
|
6
|
+
exports.runHook = exports.runCommand = exports.captureOutput = void 0;
|
|
7
|
+
const core_1 = require("@oclif/core");
|
|
8
|
+
const ansis_1 = __importDefault(require("ansis"));
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
31
10
|
const node_path_1 = require("node:path");
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
11
|
+
const debug = (0, debug_1.default)('oclif-test');
|
|
12
|
+
const RECORD_OPTIONS = {
|
|
13
|
+
print: false,
|
|
14
|
+
stripAnsi: true,
|
|
15
|
+
};
|
|
16
|
+
const originals = {
|
|
17
|
+
stderr: process.stderr.write,
|
|
18
|
+
stdout: process.stdout.write,
|
|
19
|
+
};
|
|
20
|
+
const output = {
|
|
21
|
+
stderr: [],
|
|
22
|
+
stdout: [],
|
|
23
|
+
};
|
|
24
|
+
function mockedStdout(str, encoding, cb) {
|
|
25
|
+
output.stdout.push(str);
|
|
26
|
+
if (!RECORD_OPTIONS.print)
|
|
27
|
+
return true;
|
|
28
|
+
if (typeof encoding === 'string') {
|
|
29
|
+
return originals.stdout.bind(process.stdout)(str, encoding, cb);
|
|
30
|
+
}
|
|
31
|
+
return originals.stdout.bind(process.stdout)(str, cb);
|
|
32
|
+
}
|
|
33
|
+
function mockedStderr(str, encoding, cb) {
|
|
34
|
+
output.stderr.push(str);
|
|
35
|
+
if (!RECORD_OPTIONS.print)
|
|
36
|
+
return true;
|
|
37
|
+
if (typeof encoding === 'string') {
|
|
38
|
+
return originals.stdout.bind(process.stderr)(str, encoding, cb);
|
|
39
|
+
}
|
|
40
|
+
return originals.stdout.bind(process.stderr)(str, cb);
|
|
41
|
+
}
|
|
42
|
+
const restore = () => {
|
|
43
|
+
process.stderr.write = originals.stderr;
|
|
44
|
+
process.stdout.write = originals.stdout;
|
|
45
|
+
};
|
|
46
|
+
const reset = () => {
|
|
47
|
+
output.stderr = [];
|
|
48
|
+
output.stdout = [];
|
|
49
|
+
};
|
|
50
|
+
const toString = (str) => RECORD_OPTIONS.stripAnsi ? ansis_1.default.strip(str.toString()) : str.toString();
|
|
51
|
+
const getStderr = () => output.stderr.map((b) => toString(b)).join('');
|
|
52
|
+
const getStdout = () => output.stdout.map((b) => toString(b)).join('');
|
|
36
53
|
function traverseFilePathUntil(filename, predicate) {
|
|
37
54
|
let current = filename;
|
|
38
55
|
while (!predicate(current)) {
|
|
@@ -40,24 +57,60 @@ function traverseFilePathUntil(filename, predicate) {
|
|
|
40
57
|
}
|
|
41
58
|
return current;
|
|
42
59
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
function findRoot() {
|
|
61
|
+
return (process.env.OCLIF_TEST_ROOT ??
|
|
62
|
+
// eslint-disable-next-line unicorn/prefer-module
|
|
46
63
|
Object.values(require.cache).find((m) => m?.children.includes(module))?.filename ??
|
|
47
|
-
traverseFilePathUntil(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
traverseFilePathUntil(
|
|
65
|
+
// eslint-disable-next-line unicorn/prefer-module
|
|
66
|
+
require.main?.path ?? module.path, (p) => !(p.includes('node_modules') || p.includes('.pnpm') || p.includes('.yarn'))));
|
|
67
|
+
}
|
|
68
|
+
function makeLoadOptions(loadOpts) {
|
|
69
|
+
return loadOpts ?? { root: findRoot() };
|
|
70
|
+
}
|
|
71
|
+
async function captureOutput(fn, opts) {
|
|
72
|
+
RECORD_OPTIONS.print = opts?.print ?? false;
|
|
73
|
+
RECORD_OPTIONS.stripAnsi = opts?.stripAnsi ?? true;
|
|
74
|
+
process.stderr.write = mockedStderr;
|
|
75
|
+
process.stdout.write = mockedStdout;
|
|
76
|
+
try {
|
|
77
|
+
const result = await fn();
|
|
78
|
+
return {
|
|
79
|
+
result: result,
|
|
80
|
+
stderr: getStderr(),
|
|
81
|
+
stdout: getStdout(),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
...(error instanceof core_1.Errors.CLIError && { error }),
|
|
87
|
+
...(error instanceof Error && { error }),
|
|
88
|
+
stderr: getStderr(),
|
|
89
|
+
stdout: getStdout(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
restore();
|
|
94
|
+
reset();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.captureOutput = captureOutput;
|
|
98
|
+
async function runCommand(args, loadOpts, captureOpts) {
|
|
99
|
+
const loadOptions = makeLoadOptions(loadOpts);
|
|
100
|
+
const argsArray = (Array.isArray(args) ? args : [args]).join(' ').split(' ');
|
|
101
|
+
const [id, ...rest] = argsArray;
|
|
102
|
+
const finalArgs = id === '.' ? rest : argsArray;
|
|
103
|
+
debug('loadOpts: %O', loadOpts);
|
|
104
|
+
debug('args: %O', finalArgs);
|
|
105
|
+
return captureOutput(async () => (0, core_1.run)(finalArgs, loadOptions), captureOpts);
|
|
106
|
+
}
|
|
107
|
+
exports.runCommand = runCommand;
|
|
108
|
+
async function runHook(hook, options, loadOpts, recordOpts) {
|
|
109
|
+
const loadOptions = makeLoadOptions(loadOpts);
|
|
110
|
+
debug('loadOpts: %O', loadOpts);
|
|
111
|
+
return captureOutput(async () => {
|
|
112
|
+
const config = await core_1.Config.load(loadOptions);
|
|
113
|
+
return config.runHook(hook, options);
|
|
114
|
+
}, recordOpts);
|
|
115
|
+
}
|
|
116
|
+
exports.runHook = runHook;
|
package/package.json
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oclif/test",
|
|
3
3
|
"description": "test helpers for oclif components",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.1-beta.0",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/oclif/test/issues",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
8
|
+
"ansis": "^3.2.0",
|
|
9
|
+
"debug": "^4.3.4"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@oclif/core": "^4.0.0-beta.6"
|
|
11
13
|
},
|
|
12
14
|
"devDependencies": {
|
|
13
15
|
"@commitlint/config-conventional": "^18.6.3",
|
|
16
|
+
"@oclif/core": "^4.0.0-beta.6",
|
|
14
17
|
"@oclif/prettier-config": "^0.2.1",
|
|
15
|
-
"@types/
|
|
18
|
+
"@types/chai": "^4.3.16",
|
|
19
|
+
"@types/debug": "^4.1.12",
|
|
16
20
|
"@types/mocha": "^10",
|
|
17
21
|
"@types/node": "^18",
|
|
22
|
+
"chai": "^5.1.1",
|
|
18
23
|
"commitlint": "^18.6.1",
|
|
19
24
|
"eslint": "^8.57.0",
|
|
20
25
|
"eslint-config-oclif": "^5.2.0",
|
|
@@ -23,10 +28,9 @@
|
|
|
23
28
|
"husky": "^9.0.3",
|
|
24
29
|
"lint-staged": "^15.2.2",
|
|
25
30
|
"mocha": "^10",
|
|
26
|
-
"nock": "^13.5.4",
|
|
27
31
|
"prettier": "^3.2.5",
|
|
28
32
|
"shx": "^0.3.3",
|
|
29
|
-
"
|
|
33
|
+
"tsx": "^4.10.2",
|
|
30
34
|
"typescript": "^5.4.5"
|
|
31
35
|
},
|
|
32
36
|
"engines": {
|
package/lib/command.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Interfaces } from '@oclif/core';
|
|
2
|
-
import { loadConfig } from './load-config';
|
|
3
|
-
type Context = {
|
|
4
|
-
config: Interfaces.Config;
|
|
5
|
-
expectation: string;
|
|
6
|
-
returned: unknown;
|
|
7
|
-
};
|
|
8
|
-
export declare function command(args: string | string[], opts?: loadConfig.Options): {
|
|
9
|
-
run(ctx: Context): Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
package/lib/command.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = void 0;
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
const load_config_1 = require("./load-config");
|
|
6
|
-
const castArray = (input) => {
|
|
7
|
-
if (input === undefined)
|
|
8
|
-
return [];
|
|
9
|
-
return Array.isArray(input) ? input : [input];
|
|
10
|
-
};
|
|
11
|
-
function command(args, opts = {}) {
|
|
12
|
-
return {
|
|
13
|
-
async run(ctx) {
|
|
14
|
-
if (!ctx.config || opts.reset)
|
|
15
|
-
ctx.config = await (0, load_config_1.loadConfig)(opts).run({});
|
|
16
|
-
args = castArray(args);
|
|
17
|
-
const [id, ...extra] = args;
|
|
18
|
-
let cmdId = (0, core_1.toStandardizedId)(id, ctx.config);
|
|
19
|
-
if (cmdId === '.')
|
|
20
|
-
cmdId = Symbol('SINGLE_COMMAND_CLI').toString();
|
|
21
|
-
ctx.expectation ||= `runs ${args.join(' ')}`;
|
|
22
|
-
await ctx.config.runHook('init', { argv: extra, id: cmdId });
|
|
23
|
-
ctx.returned = await ctx.config.runCommand(cmdId, extra);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.command = command;
|
package/lib/exit.d.ts
DELETED
package/lib/exit.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const chai_1 = require("chai");
|
|
4
|
-
// eslint-disable-next-line valid-jsdoc
|
|
5
|
-
/**
|
|
6
|
-
* ensures that a oclif command or hook exits
|
|
7
|
-
*/
|
|
8
|
-
exports.default = (code = 0) => ({
|
|
9
|
-
catch(ctx) {
|
|
10
|
-
if (!ctx.error.oclif || ctx.error.oclif.exit === undefined)
|
|
11
|
-
throw ctx.error;
|
|
12
|
-
(0, chai_1.expect)(ctx.error.oclif.exit).to.equal(code);
|
|
13
|
-
},
|
|
14
|
-
run() {
|
|
15
|
-
(0, chai_1.expect)(process.exitCode).to.equal(code);
|
|
16
|
-
throw new Error(`Expected to exit with code ${code} but it ran without exiting`);
|
|
17
|
-
},
|
|
18
|
-
});
|
package/lib/hook.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Interfaces } from '@oclif/core';
|
|
2
|
-
import { loadConfig } from './load-config';
|
|
3
|
-
type Context = {
|
|
4
|
-
config: Interfaces.Config;
|
|
5
|
-
expectation: string;
|
|
6
|
-
returned: unknown;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* tests a oclif hook
|
|
10
|
-
*
|
|
11
|
-
* @example <caption>check that when the 'init' hook is ran it outputs "this output"</caption>
|
|
12
|
-
* testHook('init', {id: 'mycommand'}, {stdout: true}, output => {
|
|
13
|
-
* expect(output.stdout).to.contain('this output')
|
|
14
|
-
* })
|
|
15
|
-
*
|
|
16
|
-
* @param {string} event hook to run
|
|
17
|
-
* @param {object} hookOpts options to pass to hook. Config object will be passed automatically.
|
|
18
|
-
*/
|
|
19
|
-
declare const _default: (event: string, hookOpts?: Record<string, unknown>, options?: loadConfig.Options) => {
|
|
20
|
-
run(ctx: Context): Promise<void>;
|
|
21
|
-
};
|
|
22
|
-
export default _default;
|
package/lib/hook.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const load_config_1 = require("./load-config");
|
|
4
|
-
// eslint-disable-next-line valid-jsdoc
|
|
5
|
-
/**
|
|
6
|
-
* tests a oclif hook
|
|
7
|
-
*
|
|
8
|
-
* @example <caption>check that when the 'init' hook is ran it outputs "this output"</caption>
|
|
9
|
-
* testHook('init', {id: 'mycommand'}, {stdout: true}, output => {
|
|
10
|
-
* expect(output.stdout).to.contain('this output')
|
|
11
|
-
* })
|
|
12
|
-
*
|
|
13
|
-
* @param {string} event hook to run
|
|
14
|
-
* @param {object} hookOpts options to pass to hook. Config object will be passed automatically.
|
|
15
|
-
*/
|
|
16
|
-
exports.default = (event, hookOpts = {}, options = {}) => ({
|
|
17
|
-
async run(ctx) {
|
|
18
|
-
if (!event)
|
|
19
|
-
throw new Error('no hook provided');
|
|
20
|
-
ctx.config ||= await (0, load_config_1.loadConfig)(options).run({});
|
|
21
|
-
ctx.expectation ||= `runs ${event} hook`;
|
|
22
|
-
ctx.returned = await ctx.config.runHook(event, hookOpts || {});
|
|
23
|
-
},
|
|
24
|
-
});
|
package/lib/load-config.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Interfaces } from '@oclif/core';
|
|
2
|
-
/**
|
|
3
|
-
* loads CLI plugin/multi config
|
|
4
|
-
* @param {loadConfig.Options} opts options
|
|
5
|
-
* @return {Promise<Interfaces.Config>} config
|
|
6
|
-
*/
|
|
7
|
-
export declare function loadConfig(opts?: loadConfig.Options): {
|
|
8
|
-
run(ctx: {
|
|
9
|
-
config: Interfaces.Config;
|
|
10
|
-
}): Promise<Interfaces.Config>;
|
|
11
|
-
};
|
|
12
|
-
export declare namespace loadConfig {
|
|
13
|
-
let root: string;
|
|
14
|
-
interface Options {
|
|
15
|
-
reset?: boolean;
|
|
16
|
-
root?: string;
|
|
17
|
-
}
|
|
18
|
-
}
|
package/lib/load-config.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadConfig = void 0;
|
|
4
|
-
const core_1 = require("@oclif/core");
|
|
5
|
-
/**
|
|
6
|
-
* loads CLI plugin/multi config
|
|
7
|
-
* @param {loadConfig.Options} opts options
|
|
8
|
-
* @return {Promise<Interfaces.Config>} config
|
|
9
|
-
*/
|
|
10
|
-
function loadConfig(opts = {}) {
|
|
11
|
-
return {
|
|
12
|
-
async run(ctx) {
|
|
13
|
-
ctx.config = await core_1.Config.load(opts.root || loadConfig.root);
|
|
14
|
-
return ctx.config;
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
exports.loadConfig = loadConfig;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
20
|
-
(function (loadConfig) {
|
|
21
|
-
})(loadConfig || (exports.loadConfig = loadConfig = {}));
|