11import path from 'path' ;
22import fs from 'fs-extra' ;
3- import R from 'ramda' ;
43
54export interface FileContent {
65 fileName : string ;
76 content : string ;
7+ readOnly ?: boolean ;
88}
99
1010export interface SchemaFileRepository {
@@ -41,7 +41,7 @@ export class FileRepository implements SchemaFileRepository {
4141
4242 let result = await Promise . all (
4343 files
44- . filter ( file => R . endsWith ( '.js' , file ) || R . endsWith ( '.yml' , file ) || R . endsWith ( '.yaml' , file ) )
44+ . filter ( file => file . endsWith ( '.js' ) || file . endsWith ( '.yml' ) || file . endsWith ( '.yaml' ) )
4545 . map ( async file => {
4646 const content = await fs . readFile ( path . join ( this . localPath ( ) , file ) , 'utf-8' ) ;
4747
@@ -70,7 +70,7 @@ export class FileRepository implements SchemaFileRepository {
7070
7171 const files = await Promise . all (
7272 Object . keys ( packageJson . dependencies ) . map ( async module => {
73- if ( R . endsWith ( '-schema' , module ) ) {
73+ if ( module . endsWith ( '-schema' ) ) {
7474 return this . readModuleFiles ( path . join ( 'node_modules' , module ) ) ;
7575 }
7676
@@ -81,7 +81,7 @@ export class FileRepository implements SchemaFileRepository {
8181 return files . reduce ( ( a , b ) => a . concat ( b ) ) ;
8282 }
8383
84- protected async readModuleFiles ( modulePath : string ) {
84+ protected async readModuleFiles ( modulePath : string ) : Promise < FileContent [ ] > {
8585 const files = await fs . readdir ( modulePath ) ;
8686
8787 const result = await Promise . all (
@@ -90,7 +90,7 @@ export class FileRepository implements SchemaFileRepository {
9090 const stats = await fs . lstat ( fileName ) ;
9191 if ( stats . isDirectory ( ) ) {
9292 return this . readModuleFiles ( fileName ) ;
93- } else if ( R . endsWith ( '.js' , file ) ) {
93+ } else if ( file . endsWith ( '.js' ) ) {
9494 const content = await fs . readFile ( fileName , 'utf-8' ) ;
9595 return [
9696 {
@@ -105,6 +105,6 @@ export class FileRepository implements SchemaFileRepository {
105105 } )
106106 ) ;
107107
108- return result . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ;
108+ return result . reduce < FileContent [ ] > ( ( a , b ) => a . concat ( b ) , [ ] ) ;
109109 }
110110}
0 commit comments