@@ -88,11 +88,17 @@ export const getProjectPackage = async (cwd: string): Promise<Package> => {
88
88
const projectPackagePath = await findFileInPath ( cwd ) ;
89
89
90
90
if ( projectPackagePath ) {
91
- const { name, description, version, exports, homepage } = JSON . parse (
92
- await fs . readFile ( projectPackagePath , 'utf8' )
93
- ) ;
94
-
95
- return { name, description, version, exports, homepage } ;
91
+ const { name, description, version, exports, homepage, doxdoxConfig } =
92
+ JSON . parse ( await fs . readFile ( projectPackagePath , 'utf8' ) ) ;
93
+
94
+ return {
95
+ name,
96
+ description,
97
+ version,
98
+ exports,
99
+ homepage,
100
+ doxdoxConfig
101
+ } ;
96
102
}
97
103
98
104
return { } ;
@@ -141,6 +147,33 @@ export const isFile = async (path: string): Promise<boolean> => {
141
147
}
142
148
} ;
143
149
150
+ /**
151
+ * Parse config key/value pairs from raw CLI flags.
152
+ *
153
+ * console.log(await parseConfigFromCLI([['-c', 'key=value']]));
154
+ *
155
+ * @param {[string, string | boolean][] } rawFlags Raw flags from the CLI.
156
+ * @return {{ [key in string]: string | boolean } } Configs key/value pairs.
157
+ * @public
158
+ */
159
+
160
+ export const parseConfigFromCLI = (
161
+ rawFlags : [ string , string | boolean ] [ ]
162
+ ) : {
163
+ [ key in string ] : string | boolean ;
164
+ } =>
165
+ rawFlags
166
+ . filter ( ( [ flag ] ) => [ '-c' , '--config' ] . includes ( flag ) )
167
+ . reduce ( ( all , [ , config ] ) => {
168
+ const [ key , value ] = String ( config ) . split ( '=' ) ;
169
+
170
+ if ( [ 'true' , 'false' ] . includes ( value ) ) {
171
+ return { ...all , [ key ] : value === 'true' ? true : false } ;
172
+ } else {
173
+ return { ...all , [ key ] : value } ;
174
+ }
175
+ } , { } ) ;
176
+
144
177
/**
145
178
* Parse contents of ignore file.
146
179
*
0 commit comments