Skip to content

Commit d7f5a2e

Browse files
committed
Add a new oldValue function param to the application flow
1 parent fa012f0 commit d7f5a2e

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/lib/utils/options/declaration.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,8 @@ const converters: {
429429
[K in ParameterType]: (
430430
value: unknown,
431431
option: DeclarationOption & { type: K },
432-
configPath: string
432+
configPath: string,
433+
oldValue: unknown
433434
) => ParameterTypeToOptionTypeMap[K];
434435
} = {
435436
[ParameterType.String](value, option) {
@@ -580,16 +581,18 @@ const converters: {
580581
export function convert(
581582
value: unknown,
582583
option: DeclarationOption,
583-
configPath: string
584+
configPath: string,
585+
oldValue?: unknown
584586
): unknown {
585587
const _converters = converters as Record<
586588
ParameterType,
587-
(v: unknown, o: DeclarationOption, c: string) => unknown
589+
(v: unknown, o: DeclarationOption, c: string, ov: unknown) => unknown
588590
>;
589591
return _converters[option.type ?? ParameterType.String](
590592
value,
591593
option,
592-
configPath
594+
configPath,
595+
oldValue
593596
);
594597
}
595598

src/lib/utils/options/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,15 @@ export class Options {
301301
);
302302
}
303303

304+
let oldValue = this._values[declaration.name];
305+
if (typeof oldValue === "undefined")
306+
oldValue = getDefaultValue(declaration);
307+
304308
const converted = convert(
305309
value,
306310
declaration,
307-
configPath ?? process.cwd()
311+
configPath ?? process.cwd(),
312+
oldValue
308313
);
309314

310315
if (declaration.type === ParameterType.Flags) {

0 commit comments

Comments
 (0)