File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env node
22import yargs from 'yargs' ;
33import { hideBin } from 'yargs/helpers' ;
4+ import { CONFIG_FILE_FORMATS } from './lib/setup/types.js' ;
45import { runSetupWizard } from './lib/setup/wizard.js' ;
56
67const argv = await yargs ( hideBin ( process . argv ) )
@@ -17,7 +18,7 @@ const argv = await yargs(hideBin(process.argv))
1718 } )
1819 . option ( 'config-format' , {
1920 type : 'string' ,
20- choices : [ 'ts' , 'js' , 'mjs' ] ,
21+ choices : CONFIG_FILE_FORMATS ,
2122 describe : 'Config file format (default: auto-detected from project)' ,
2223 } )
2324 . parse ( ) ;
Original file line number Diff line number Diff line change @@ -3,7 +3,11 @@ import { readdir } from 'node:fs/promises';
33import path from 'node:path' ;
44import type { PackageJson } from 'type-fest' ;
55import { fileExists , readJsonFile } from '@code-pushup/utils' ;
6- import type { CliArgs , ConfigFileFormat } from './types.js' ;
6+ import {
7+ CONFIG_FILE_FORMATS ,
8+ type CliArgs ,
9+ type ConfigFileFormat ,
10+ } from './types.js' ;
711
812const TSCONFIG_PATTERN = / ^ t s c o n f i g ( \. .+ ) ? \. j s o n $ / ;
913
@@ -61,5 +65,6 @@ async function detectDefaultFormat(targetDir: string): Promise<DefaultFormat> {
6165function isConfigFileFormat (
6266 value : string | undefined ,
6367) : value is ConfigFileFormat {
64- return value === 'ts' || value === 'js' || value === 'mjs' ;
68+ const validValues : readonly string [ ] = CONFIG_FILE_FORMATS ;
69+ return value != null && validValues . includes ( value ) ;
6570}
Original file line number Diff line number Diff line change 11import type { PluginMeta } from '@code-pushup/models' ;
22
3- export type ConfigFileFormat = 'ts' | 'js' | 'mjs' ;
3+ export const CONFIG_FILE_FORMATS = [ 'ts' , 'js' , 'mjs' ] as const ;
4+ export type ConfigFileFormat = ( typeof CONFIG_FILE_FORMATS ) [ number ] ;
45
56/** Virtual file system that buffers writes in memory until flushed to disk. */
67export type Tree = {
You can’t perform that action at this time.
0 commit comments