File tree 4 files changed +16
-3
lines changed
4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @khanacademy/graphql-flow ' : patch
3
+ ---
4
+
5
+ Search through untracked files for graphql-tag. Don't error out on files that can't be found.
Original file line number Diff line number Diff line change @@ -32,8 +32,11 @@ import {dirname} from 'path';
32
32
/** Step (1) */
33
33
34
34
const findGraphqlTagReferences = ( root : string ) : Array < string > => {
35
+ // NOTE(john): We want to include untracked files here so that we can
36
+ // generate types for them. This is useful for when we have a new file
37
+ // that we want to generate types for, but we haven't committed it yet.
35
38
const response = execSync (
36
- "git grep -I --word-regexp --name-only --fixed-strings 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'" ,
39
+ "git grep -I --word-regexp --name-only --fixed-strings --untracked 'graphql-tag' -- '*.js' '*.jsx' '*.ts' '*.tsx'" ,
37
40
{
38
41
encoding : 'utf8' ,
39
42
cwd : root ,
Original file line number Diff line number Diff line change @@ -105,7 +105,9 @@ const listExternalReferences = (file: FileResult): Array<string> => {
105
105
if ( v . type === 'import' ) {
106
106
if ( followImports ) {
107
107
const absPath = getPathWithExtension ( v . path ) ;
108
- paths [ absPath ] = true ;
108
+ if ( absPath ) {
109
+ paths [ absPath ] = true ;
110
+ }
109
111
}
110
112
} else {
111
113
v . source . expressions . forEach ( ( expr ) => add ( expr , true ) ) ;
Original file line number Diff line number Diff line change @@ -20,5 +20,8 @@ export const getPathWithExtension = (pathWithoutExtension: string): string => {
20
20
if ( fs . existsSync ( pathWithoutExtension + '.ts' ) ) {
21
21
return pathWithoutExtension + '.ts' ;
22
22
}
23
- throw new Error ( "Can't find file at " + pathWithoutExtension ) ;
23
+ // NOTE(john): This is a bit of a hack, but it's necessary for when we
24
+ // have a file that doesn't have an extension. This will happen when we
25
+ // delete all of the type files before re-running graphql-flow again.
26
+ return "" ;
24
27
} ;
You can’t perform that action at this time.
0 commit comments