Skip to content

Commit 4e842ac

Browse files
author
Tonye Jack
committed
Updated to include verbose output.
1 parent 1b02e21 commit 4e842ac

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

bin/graphql-codegen-hook.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ const minimatch = require('minimatch');
55
const shell = require('shelljs');
66

77
const argv = require('yargs')
8-
.option('config', { alias: 'c', required: true, type: 'string', description: 'Yaml config file' })
8+
.option(
9+
'config',
10+
{
11+
alias: 'c',
12+
required: true,
13+
type: 'string',
14+
description: 'Yaml config file'
15+
},
16+
)
917
.option(
1018
'verbose',
1119
{
@@ -22,13 +30,21 @@ const argv = require('yargs')
2230
.help()
2331
.argv;
2432

25-
const { filenames = [] } = argv;
26-
const fileMatches = filenames.filter(minimatch.filter("*.+(tsx|jsx|js|ts)", { matchBase: true }));
33+
const { filenames = [], verbose = false } = argv;
34+
const fileMatches = filenames.filter(
35+
minimatch.filter("*.+(tsx|jsx|js|ts)", { matchBase: true }),
36+
);
2737
const shouldExecute = fileMatches.length > 0;
2838

2939
if (!shouldExecute) {
30-
shell.exit(0);
40+
if (verbose) {
41+
shell.echo('No matching files found requires: js(x)|ts(x)');
42+
}
43+
return 0;
3144
} else {
45+
if (verbose) {
46+
shell.echo(`Matching files found: ${fileMatches.join(', ')}`);
47+
}
3248
const basePath = shell.pwd().toString();
3349

3450
shell.cd(basePath);

0 commit comments

Comments
 (0)