Skip to content

Commit 3d0e59c

Browse files
committed
[Update] code style
1 parent 341347f commit 3d0e59c

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/api/typeDefs/index.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface IgqlTsOpts {
1515
outFile?: string;
1616
}
1717

18-
const defaults: IgqlTsOpts = {
18+
const defaults: IgqlTsOpts = {
1919
globPattern: '**/*.gql',
2020
outFile: ''
2121
};
@@ -24,14 +24,16 @@ const readFile: (fileName: string) => Promise<string> =
2424
(fileName) => fs.readFile(fileName, 'utf8');
2525

2626
const getGlobbedFilesLoad: (globPattern: string) => Promise<string[]> = async (globPattern) => {
27-
const files: string[] = await glob(globPattern);
27+
const files: string[] = await glob(globPattern);
2828
const load: string[] = await Promise.all(R.map(readFile, files));
29+
2930
return load;
3031
};
3132

32-
export const getTypeDefs: (globPattern?: string) => Promise<string> = async (globPattern = '**/*.gql') => {
33+
export const getTypeDefs: (globPattern?: string) => Promise<any> = async (globPattern = '**/*.gql') => {
3334
try {
3435
const typesLoad: string[] = await getGlobbedFilesLoad(globPattern);
36+
3537
return mergeTypes(typesLoad);
3638
} catch (error) {
3739
console.error(error);
@@ -40,18 +42,19 @@ export const getTypeDefs: (globPattern?: string) => Promise<string> = async (glo
4042

4143
const addAutoGeneratedWarning = (tsTypes: string): string => {
4244
return `// This file is auto generated by the gqlToTs.ts module\n${tsTypes}`;
43-
};
45+
};
4446

45-
export const generateTsFromGql: (options?: IgqlTsOpts) => Promise <string | any> = async (options = {}) => {
47+
export const generateTsFromGql: (options?: IgqlTsOpts) => Promise <string | any> = async (options = {}) => {
4648
// check whether we have args
47-
const namespace = process.argv[2] || 'DH';
49+
const namespace = process.argv[2] || 'DH';
4850
console.log('created type definitions with: ', namespace, ' namespace');
49-
const opts = Object.assign(defaults, options);
51+
const opts = { ...defaults, ...options };
5052
try {
5153
const typeDefs: string = await getTypeDefs(opts.globPattern);
52-
const namespaceOpts = { ignoreTypeNameDeclaration: true};
54+
const namespaceOpts = { ignoreTypeNameDeclaration: true };
5355
const tsNameSpace: string = generateNamespace(namespace, typeDefs, namespaceOpts, {});
54-
if (opts.outFile && opts.outFile.length) fs.writeFile(opts.outFile, addAutoGeneratedWarning(tsNameSpace));
56+
if (opts.outFile && opts.outFile.length) { fs.writeFile(opts.outFile, addAutoGeneratedWarning(tsNameSpace)); }
57+
5558
return tsNameSpace;
5659
} catch (error) {
5760
console.error(error);
@@ -60,5 +63,5 @@ export const generateTsFromGql: (options?: IgqlTsOpts) => Promise <string | any
6063

6164
if (require.main === module && process.env.NODE_ENV !== 'test') {
6265
// this module was run directly from the command line as in node xxx.js
63-
generateTsFromGql({outFile: 'index.d.ts'});
66+
generateTsFromGql({ outFile: 'index.d.ts' });
6467
}

0 commit comments

Comments
 (0)