diff --git a/src/cli.ts b/src/cli.ts index d16ad903..7d14335d 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -35,6 +35,7 @@ export interface Logger { export interface Options { dryRun: boolean; + binPrefix: string; gtsRootDir: string; targetRootDir: string; yes: boolean; @@ -69,6 +70,7 @@ const cli = meow({ -n, --no Assume a no answer for every prompt. --dry-run Don't make any actual changes. --yarn Use yarn instead of npm. + --bin-prefix Directory containing node_modules. Used for running eslint. Examples $ gts init -y @@ -81,6 +83,7 @@ const cli = meow({ yes: {type: 'boolean', alias: 'y'}, no: {type: 'boolean', alias: 'n'}, dryRun: {type: 'boolean'}, + binPrefix: {type: 'string'}, yarn: {type: 'boolean'}, }, }); @@ -115,6 +118,7 @@ export async function run(verb: string, files: string[]): Promise { const options = { dryRun: cli.flags.dryRun || false, + binPrefix: cli.flags.binPrefix || '.', // Paths are relative to the transpiled output files. gtsRootDir: path.resolve(__dirname, '../..'), targetRootDir: process.cwd(), @@ -145,7 +149,7 @@ export async function run(verb: string, files: string[]): Promise { case 'lint': case 'check': { try { - await execa('node', ['./node_modules/eslint/bin/eslint', ...flags], { + await execa('node', [options.binPrefix + '/node_modules/eslint/bin/eslint', ...flags], { stdio: 'inherit', }); return true; @@ -158,7 +162,7 @@ export async function run(verb: string, files: string[]): Promise { try { await execa( 'node', - ['./node_modules/eslint/bin/eslint', fixFlag, ...flags], + [options.binPrefix + '/node_modules/eslint/bin/eslint', fixFlag, ...flags], { stdio: 'inherit', }