11const path = require ( 'path' ) ;
22const fs = require ( 'fs' ) ;
33
4- const cwdPath = ( file ) => path . join ( process . env [ 'INIT_CWD' ] || process . cwd ( ) , file ) ;
4+ const cwdPath = ( file ) =>
5+ path . join ( process . env [ 'INIT_CWD' ] || process . cwd ( ) , file ) ;
56
67const getConfig = ( ) => {
78 const packageJsonFilename = cwdPath ( 'package.json' ) ;
@@ -11,51 +12,55 @@ const getConfig = () => {
1112
1213const getLicense = ( ) => {
1314 const envKey = process . env . MAXMIND_LICENSE_KEY ;
14- if ( envKey ) return envKey ;
15-
15+ if ( envKey ) return envKey ;
16+
1617 const config = getConfig ( ) ;
1718 const licenseKey = config [ 'license-key' ] ;
18- if ( licenseKey ) return licenseKey ;
19+ if ( licenseKey ) return licenseKey ;
1920
2021 const configFile = config [ 'license-file' ] ;
21- if ( ! configFile ) return ;
22+ if ( ! configFile ) return ;
2223
2324 const configFilePath = cwdPath ( configFile ) ;
24- return fs . existsSync ( configFilePath )
25- ? fs . readFileSync ( configFilePath , 'utf8' ) . trim ( )
26- : undefined ;
27- }
25+ return fs . existsSync ( configFilePath )
26+ ? fs . readFileSync ( configFilePath , 'utf8' ) . trim ( )
27+ : undefined ;
28+ } ;
2829
29- const selectedDbs = ( ) => {
30+ const getSelectedDbs = ( ) => {
3031 const config = getConfig ( ) ;
3132 const selected = config [ 'selected-dbs' ] ;
3233 const valids = [ 'City' , 'Country' , 'ASN' ] ;
33- if ( ! selected ) return valids ;
34- if ( ! Array . isArray ( selected ) ) {
34+ if ( ! selected ) return valids ;
35+ if ( ! Array . isArray ( selected ) ) {
3536 console . error ( 'selected-dbs property must have be an array.' ) ;
3637 process . exit ( 1 ) ;
3738 }
3839
39- if ( selected . length === 0 ) return valids ;
40+ if ( selected . length === 0 ) return valids ;
4041
41- if ( selected . length > 3 ) {
42- console . error ( 'selected-dbs has too many values, there are only three valid values: City, Country, ASN.' ) ;
42+ if ( selected . length > 3 ) {
43+ console . error (
44+ `selected-dbs has too many values, there are only three valid values: ${ valids . join ( ', ' ) } .`
45+ ) ;
4346 process . exit ( 1 ) ;
4447 }
4548
46- for ( const value of selected ) {
49+ for ( const value of selected ) {
4750 const index = valids . indexOf ( value ) ;
48- if ( index === - 1 ) {
49- console . error ( `Invalid value in selected-dbs: ${ value } . The only valid values are: City, Country, ASN.` ) ;
51+ if ( index === - 1 ) {
52+ console . error (
53+ `Invalid value in selected-dbs: ${ value } . The only valid values are: ${ valids . join ( ', ' ) } .`
54+ ) ;
5055 process . exit ( 1 ) ;
5156 }
5257 }
5358
5459 return selected ;
55- }
60+ } ;
5661
5762module . exports = {
5863 getConfig,
5964 getLicense,
60- selectedDbs
61- }
65+ getSelectedDbs ,
66+ } ;
0 commit comments