From a57841272a2debff19a0e9be04c81ebef92e2783 Mon Sep 17 00:00:00 2001 From: Alice Pote Date: Fri, 22 Jul 2022 12:35:28 -0400 Subject: [PATCH] restore param so as not to break API stability --- src/cli/parse-flags.ts | 6 ++++-- src/cli/public.ts | 3 ++- src/testing/jest/test/jest-config.spec.ts | 26 +++++++++++------------ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/cli/parse-flags.ts b/src/cli/parse-flags.ts index d4a14c07546..9e1a2a5c937 100644 --- a/src/cli/parse-flags.ts +++ b/src/cli/parse-flags.ts @@ -1,4 +1,4 @@ -import { LogLevel, LOG_LEVELS, TaskCommand } from '../declarations'; +import { CompilerSystem, LogLevel, LOG_LEVELS, TaskCommand } from '../declarations'; import { dashToPascalCase, toDashCase } from '@utils'; import { BOOLEAN_CLI_ARGS, @@ -20,9 +20,11 @@ import { * Parse command line arguments into a structured `ConfigFlags` object * * @param args an array of CLI flags + * @param _sys an optional compiler system * @returns a structured ConfigFlags object */ -export const parseFlags = (args: string[]): ConfigFlags => { +export const parseFlags = (args: string[], _sys?: CompilerSystem): ConfigFlags => { + // TODO(STENCIL-509): remove the _sys parameter here ^^ (for v3) const flags: ConfigFlags = createConfigFlags(); // cmd line has more priority over npm scripts cmd diff --git a/src/cli/public.ts b/src/cli/public.ts index c872e8feba1..57c7526745d 100644 --- a/src/cli/public.ts +++ b/src/cli/public.ts @@ -15,6 +15,7 @@ export declare function run(init: CliInitOptions): Promise; */ export declare function runTask(coreCompiler: any, config: Config, task: TaskCommand): Promise; -export declare function parseFlags(args: string[], sys?: CompilerSystem): ConfigFlags; +// TODO(STENCIL-509): remove the _sys parameter here (for v3) +export declare function parseFlags(args: string[], _sys?: CompilerSystem): ConfigFlags; export { CompilerSystem, Config, ConfigFlags, Logger, TaskCommand }; diff --git a/src/testing/jest/test/jest-config.spec.ts b/src/testing/jest/test/jest-config.spec.ts index ee6e083a8eb..65d043d11ba 100644 --- a/src/testing/jest/test/jest-config.spec.ts +++ b/src/testing/jest/test/jest-config.spec.ts @@ -8,7 +8,7 @@ describe('jest-config', () => { it('pass --maxWorkers=2 arg when --max-workers=2', () => { const args = ['test', '--ci', '--max-workers=2']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--ci', '--max-workers=2']); expect(config.flags.unknownArgs).toEqual([]); @@ -21,7 +21,7 @@ describe('jest-config', () => { it('marks outputFile as a Jest argument', () => { const args = ['test', '--ci', '--outputFile=path/to/my-file']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--ci', '--outputFile=path/to/my-file']); expect(config.flags.unknownArgs).toEqual([]); const jestArgv = buildJestArgv(config); @@ -31,7 +31,7 @@ describe('jest-config', () => { it('pass --maxWorkers=2 arg when e2e test and --ci', () => { const args = ['test', '--ci', '--e2e', '--max-workers=2']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--ci', '--e2e', '--max-workers=2']); expect(config.flags.unknownArgs).toEqual([]); @@ -44,7 +44,7 @@ describe('jest-config', () => { it('forces --maxWorkers=4 arg when e2e test and --ci', () => { const args = ['test', '--ci', '--e2e']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--ci', '--e2e']); expect(config.flags.unknownArgs).toEqual([]); @@ -57,7 +57,7 @@ describe('jest-config', () => { it('pass --maxWorkers=2 arg to jest', () => { const args = ['test', '--maxWorkers=2']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--maxWorkers=2']); expect(config.flags.unknownArgs).toEqual([]); @@ -69,7 +69,7 @@ describe('jest-config', () => { it('pass --ci arg to jest', () => { const args = ['test', '--ci']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--ci']); expect(config.flags.unknownArgs).toEqual([]); @@ -82,7 +82,7 @@ describe('jest-config', () => { it('sets legacy jest options', () => { const args = ['test']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); const jestArgv = buildJestArgv(config); @@ -111,7 +111,7 @@ describe('jest-config', () => { it('pass test spec arg to jest', () => { const args = ['test', 'hello.spec.ts']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['hello.spec.ts']); expect(config.flags.unknownArgs).toEqual(['hello.spec.ts']); @@ -127,7 +127,7 @@ describe('jest-config', () => { testMatch: ['hello.spec.ts'], }, }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.task).toBe('test'); @@ -143,7 +143,7 @@ describe('jest-config', () => { rootDir, testing: { reporters: ['default', ['jest-junit', { suiteName: 'jest tests' }]] }, }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); const jestArgv = buildJestArgv(config); const parsedConfig = JSON.parse(jestArgv.config) as d.JestConfig; @@ -157,7 +157,7 @@ describe('jest-config', () => { const rootDir = path.resolve('/'); const args = ['test']; const config = mockValidatedConfig({ rootDir, testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); const jestArgv = buildJestArgv(config); const parsedConfig = JSON.parse(jestArgv.config) as d.JestConfig; @@ -168,7 +168,7 @@ describe('jest-config', () => { const rootDir = path.resolve('/'); const args = ['test']; const config = mockValidatedConfig({ rootDir, testing: { collectCoverageFrom: ['**/*.+(ts|tsx)'] } }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); const jestArgv = buildJestArgv(config); const parsedConfig = JSON.parse(jestArgv.config) as d.JestConfig; @@ -179,7 +179,7 @@ describe('jest-config', () => { it('passed flags should be respected over defaults', () => { const args = ['test', '--spec', '--passWithNoTests']; const config = mockValidatedConfig({ testing: {} }); - config.flags = parseFlags(args, config.sys); + config.flags = parseFlags(args); expect(config.flags.args).toEqual(['--spec', '--passWithNoTests']); expect(config.flags.unknownArgs).toEqual([]);