Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface Logger {

export interface Options {
dryRun: boolean;
binPrefix: string;
gtsRootDir: string;
targetRootDir: string;
yes: boolean;
Expand Down Expand Up @@ -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
Expand All @@ -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'},
},
});
Expand Down Expand Up @@ -115,6 +118,7 @@ export async function run(verb: string, files: string[]): Promise<boolean> {

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(),
Expand Down Expand Up @@ -145,7 +149,7 @@ export async function run(verb: string, files: string[]): Promise<boolean> {
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;
Expand All @@ -158,7 +162,7 @@ export async function run(verb: string, files: string[]): Promise<boolean> {
try {
await execa(
'node',
['./node_modules/eslint/bin/eslint', fixFlag, ...flags],
[options.binPrefix + '/node_modules/eslint/bin/eslint', fixFlag, ...flags],
{
stdio: 'inherit',
}
Expand Down