Keep boolean | string for inspect types, map in command handlers
Move the empty-string-to-boolean conversion from cleye's String type into the command handlers so that startPackage/runBackend keep their existing boolean | string interface. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -86,8 +86,8 @@ export default async ({ args, info }: CommandContext) => {
|
||||
configPaths: config,
|
||||
checksEnabled: Boolean(check),
|
||||
linkedWorkspace: await resolveLinkedWorkspace(link),
|
||||
inspectEnabled: inspect,
|
||||
inspectBrkEnabled: inspectBrk,
|
||||
inspectEnabled: inspect || (inspect === '' ? true : undefined),
|
||||
inspectBrkEnabled: inspectBrk || (inspectBrk === '' ? true : undefined),
|
||||
require: requirePath,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -23,8 +23,8 @@ import { runBackend } from '../../../lib/runner';
|
||||
interface StartBackendOptions {
|
||||
targetDir: string;
|
||||
checksEnabled: boolean;
|
||||
inspectEnabled?: string;
|
||||
inspectBrkEnabled?: string;
|
||||
inspectEnabled?: boolean | string;
|
||||
inspectBrkEnabled?: boolean | string;
|
||||
linkedWorkspace?: string;
|
||||
require?: string;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ export async function startPackage(options: {
|
||||
targetDir: string;
|
||||
configPaths: string[];
|
||||
checksEnabled: boolean;
|
||||
inspectEnabled?: string;
|
||||
inspectBrkEnabled?: string;
|
||||
inspectEnabled?: boolean | string;
|
||||
inspectBrkEnabled?: boolean | string;
|
||||
linkedWorkspace?: string;
|
||||
require?: string;
|
||||
}): Promise<void> {
|
||||
|
||||
@@ -84,8 +84,8 @@ export default async ({ args, info }: CommandContext) => {
|
||||
const packageOptions = await resolvePackageOptions(targetPackages, {
|
||||
plugin,
|
||||
config,
|
||||
inspect,
|
||||
inspectBrk,
|
||||
inspect: inspect || (inspect === '' ? true : undefined),
|
||||
inspectBrk: inspectBrk || (inspectBrk === '' ? true : undefined),
|
||||
require: requirePath,
|
||||
link,
|
||||
});
|
||||
@@ -211,8 +211,8 @@ export async function findTargetPackages(
|
||||
type CommandOptions = {
|
||||
plugin: string[];
|
||||
config: string[];
|
||||
inspect?: string;
|
||||
inspectBrk?: string;
|
||||
inspect?: boolean | string;
|
||||
inspectBrk?: boolean | string;
|
||||
require?: string;
|
||||
link?: string;
|
||||
};
|
||||
|
||||
@@ -163,7 +163,7 @@ describe('runBackend', () => {
|
||||
|
||||
runBackend({
|
||||
entry: 'src/index',
|
||||
inspectEnabled: '',
|
||||
inspectEnabled: true,
|
||||
});
|
||||
|
||||
// Fast-forward past the debounce delay (100ms)
|
||||
|
||||
@@ -38,9 +38,9 @@ export type RunBackendOptions = {
|
||||
/** relative entry point path without extension, e.g. 'src/index' */
|
||||
entry: string;
|
||||
/** Whether to forward the --inspect flag to the node process */
|
||||
inspectEnabled?: string;
|
||||
inspectEnabled?: boolean | string;
|
||||
/** Whether to forward the --inspect-brk flag to the node process */
|
||||
inspectBrkEnabled?: string;
|
||||
inspectBrkEnabled?: boolean | string;
|
||||
/** Additional module to require via the --require flag to the node process */
|
||||
require?: string | string[];
|
||||
/** An external linked workspace to override module resolution towards */
|
||||
@@ -96,18 +96,18 @@ export async function runBackend(options: RunBackendOptions) {
|
||||
}
|
||||
|
||||
const optionArgs = new Array<string>();
|
||||
if (options.inspectEnabled !== undefined) {
|
||||
optionArgs.push(
|
||||
options.inspectEnabled
|
||||
if (options.inspectEnabled) {
|
||||
const inspect =
|
||||
typeof options.inspectEnabled === 'string'
|
||||
? `--inspect=${options.inspectEnabled}`
|
||||
: '--inspect',
|
||||
);
|
||||
} else if (options.inspectBrkEnabled !== undefined) {
|
||||
optionArgs.push(
|
||||
options.inspectBrkEnabled
|
||||
: '--inspect';
|
||||
optionArgs.push(inspect);
|
||||
} else if (options.inspectBrkEnabled) {
|
||||
const inspect =
|
||||
typeof options.inspectBrkEnabled === 'string'
|
||||
? `--inspect-brk=${options.inspectBrkEnabled}`
|
||||
: '--inspect-brk',
|
||||
);
|
||||
: '--inspect-brk';
|
||||
optionArgs.push(inspect);
|
||||
}
|
||||
if (options.require) {
|
||||
const requires = [options.require].flat();
|
||||
|
||||
Reference in New Issue
Block a user