@@ -20,6 +20,7 @@ export const globalConfigFilePath = path.resolve(process.env.HOME + '/.nlu/globa
2020
2121export const validateConfigFile = ( data : NluConf ) => {
2222
23+
2324 try {
2425 const ajv = new Ajv ( { allErrors : false } ) ; // options can be passed, e.g. {allErrors: true}
2526 const validate = ajv . compile ( schema ) ;
@@ -106,6 +107,7 @@ export const getDevKeys = (pkg: PkgJSON) => {
106107 . concat ( Object . keys ( pkg . optionalDependencies || { } ) ) ;
107108} ;
108109
110+
109111export const validateOptions = ( opts : any ) => {
110112
111113 try {
@@ -121,13 +123,15 @@ export const validateOptions = (opts: any) => {
121123
122124} ;
123125
126+
124127export const mapConfigObject = ( obj : any ) => {
125128 return Object . keys ( obj ) . reduce ( ( a , b ) => {
126129 const key = String ( b ) . replace ( / [ ^ a - z A - z ] + / g, '_' ) . toLowerCase ( ) ;
127130 return ( a [ key ] = obj [ b ] , a ) ;
128131 } , { } as any ) ;
129132} ;
130133
134+
131135const checkPackages = ( dep : NluMapItem , m : Map < string , string > , sym : Set < string > ) : boolean => {
132136
133137 const d = dep . package . dependencies || { } ;
@@ -192,6 +196,7 @@ export const determineIfReinstallIsNeeded = (nodeModulesPath: string, dep: NluMa
192196 return process . nextTick ( cb ) ;
193197 }
194198
199+
195200 fs . readdir ( nodeModulesPath , ( err , originalItemsInNodeModules ) => {
196201
197202 if ( err || ! Array . isArray ( originalItemsInNodeModules ) ) {
@@ -208,6 +213,7 @@ export const determineIfReinstallIsNeeded = (nodeModulesPath: string, dep: NluMa
208213 return ! String ( v ) . startsWith ( '@' ) && String ( v ) !== '.bin' ;
209214 } ) ;
210215
216+
211217 const totalValid = new Set ( topLevel . slice ( 0 ) ) ;
212218
213219 const processFolder = ( name : string , folder : string , cb : EVCb < null > ) => {
@@ -309,7 +315,7 @@ export const determineIfReinstallIsNeeded = (nodeModulesPath: string, dep: NluMa
309315 if ( err && result . install === true ) {
310316 return cb ( null , true ) ;
311317 }
312-
318+
313319 if ( err ) {
314320 return cb ( err , false ) ;
315321 }
@@ -338,10 +344,11 @@ export const determineIfReinstallIsNeeded = (nodeModulesPath: string, dep: NluMa
338344 return cb ( null , true ) ;
339345 }
340346
347+
341348 if ( checkPackages ( dep , map , sym ) ) {
342349 return cb ( null , true ) ;
343350 }
344-
351+
345352 cb ( null , false ) ;
346353
347354 } ) ;
0 commit comments