Skip to content

Commit

Permalink
Update files that don't match new config
Browse files Browse the repository at this point in the history
  • Loading branch information
calebegg committed Oct 21, 2023
1 parent 813f0ed commit 51d2da8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/clean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function clean(options: Options): Promise<boolean> {
if (outDir === '.') {
options.logger.error(
`${chalk.red('ERROR:')} ${chalk.gray('compilerOptions.outDir')} ` +
'cannot use the value ".". That would delete all of our sources.'
'cannot use the value ".". That would delete all of our sources.',
);
return false;
}
Expand All @@ -45,7 +45,7 @@ export async function clean(options: Options): Promise<boolean> {
options.logger.error(
`${chalk.red('ERROR:')} The ${chalk.gray('clean')} command` +
` requires ${chalk.gray('compilerOptions.outDir')} to be defined in ` +
'tsconfig.json.'
'tsconfig.json.',
);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export interface Options {
export type VerbFilesFunction = (
options: Options,
files: string[],
fix?: boolean
fix?: boolean,
) => Promise<boolean>;

const logger: Logger = console;
Expand Down Expand Up @@ -105,7 +105,7 @@ export async function run(verb: string, files: string[]): Promise<boolean> {
throw new Error(
`gts requires node.js 10.x or up. You are currently running
${process.version}, which is not supported. Please upgrade to
a safe, secure version of nodejs!`
a safe, secure version of nodejs!`,
);
}

Expand Down Expand Up @@ -133,7 +133,7 @@ export async function run(verb: string, files: string[]): Promise<boolean> {
'**/*.js',
'**/*.tsx',
'**/*.jsx',
'--no-error-on-unmatched-pattern'
'--no-error-on-unmatched-pattern',
);
}

Expand Down
22 changes: 11 additions & 11 deletions src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function query(
message: string,
question: string,
defaultVal: boolean,
options: Options
options: Options,
): Promise<boolean> {
if (options.yes) {
return true;
Expand All @@ -77,7 +77,7 @@ async function query(

export async function addScripts(
packageJson: PackageJson,
options: Options
options: Options,
): Promise<boolean> {
let edits = false;
const pkgManager = getPkgManagerCommand(options.yarn);
Expand Down Expand Up @@ -120,7 +120,7 @@ export async function addScripts(

export async function addDependencies(
packageJson: PackageJson,
options: Options
options: Options,
): Promise<boolean> {
let edits = false;
const deps: DefaultPackage = {
Expand Down Expand Up @@ -164,7 +164,7 @@ function formatJson(object: {}) {

async function writePackageJson(
packageJson: PackageJson,
options: Options
options: Options,
): Promise<void> {
options.logger.log('Writing package.json...');
if (!options.dryRun) {
Expand All @@ -186,7 +186,7 @@ export const ESLINT_IGNORE = 'build/\n';
async function generateConfigFile(
options: Options,
filename: string,
contents: string
contents: string,
) {
let existing;
try {
Expand All @@ -209,7 +209,7 @@ async function generateConfigFile(
`${chalk.bold(filename)} already exists`,
'Overwrite',
false,
options
options,
);
}

Expand All @@ -226,7 +226,7 @@ async function generateESLintConfig(options: Options): Promise<void> {
return generateConfigFile(
options,
'./.eslintrc.json',
formatJson(ESLINT_CONFIG)
formatJson(ESLINT_CONFIG),
);
}

Expand Down Expand Up @@ -265,7 +265,7 @@ insert_final_newline = true
}

export async function installDefaultTemplate(
options: Options
options: Options,
): Promise<boolean> {
const cwd = process.cwd();
const sourceDirName = path.join(__dirname, '../template');
Expand All @@ -287,7 +287,7 @@ export async function installDefaultTemplate(
if (tsFiles.length !== 0) {
options.logger.log(
'Target src directory already has ts files. ' +
'Template files not installed.'
'Template files not installed.',
);
return false;
}
Expand All @@ -310,7 +310,7 @@ export async function init(options: Options): Promise<boolean> {
`${chalk.bold('package.json')} does not exist.`,
'Generate',
true,
options
options,
);

if (!generate) {
Expand Down Expand Up @@ -344,7 +344,7 @@ export async function init(options: Options): Promise<boolean> {
cp.spawnSync(
getPkgManagerCommand(options.yarn),
['install', '--ignore-scripts'],
{stdio: 'inherit'}
{stdio: 'inherit'},
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function getBase(
filePath: string,
customReadFilep: ReadFileP,
readFiles: Set<string>,
currentDir: string
currentDir: string,
): Promise<ConfigFile> {
customReadFilep = customReadFilep || readFilep;

Expand Down Expand Up @@ -92,7 +92,7 @@ async function getBase(
contents.extends,
customReadFilep,
readFiles,
path.dirname(filePath)
path.dirname(filePath),
);
contents = combineTSConfig(nextFile, contents);
}
Expand All @@ -117,7 +117,7 @@ function combineTSConfig(base: ConfigFile, inherited: ConfigFile): ConfigFile {
Object.assign(
result.compilerOptions!,
base.compilerOptions!,
inherited.compilerOptions!
inherited.compilerOptions!,
);
delete result.extends;
return result;
Expand Down Expand Up @@ -161,7 +161,7 @@ export function getPkgManagerCommand(isYarnUsed?: boolean): string {
*/
export async function getTSConfig(
rootDir: string,
customReadFilep?: ReadFileP
customReadFilep?: ReadFileP,
): Promise<ConfigFile> {
customReadFilep = (customReadFilep || readFilep) as ReadFileP;
const readArr = new Set<string>();
Expand Down

0 comments on commit 51d2da8

Please sign in to comment.