@@ -186,17 +186,6 @@ function groupDependencyTree(tree, cwd, bindingPrefix) {
186
186
return result ;
187
187
}
188
188
189
- /**
190
- * Group missing dependencies by types (files, bits, packages)
191
- * @param {Array } missing list of missing paths to group
192
- * @returns {Function } function which group the dependencies
193
- */
194
- const byPathType = R . groupBy ( ( missing ) => {
195
- return missing . startsWith ( 'bit/' ) ? 'bits' :
196
- missing . startsWith ( '.' ) ? 'files' :
197
- 'packages' ;
198
- } ) ;
199
-
200
189
/**
201
190
* Get an import statement path to node package and return the package name
202
191
*
@@ -244,10 +233,23 @@ function resolveModulePath(nmPath, workingDir, root) {
244
233
* to object with missing types
245
234
*
246
235
* @param {Array } missing
236
+ * @param {string } cwd
237
+ * @param {string } consumerPath
238
+ * @param {string } bindingPrefix
247
239
* @returns new object with grouped missing
248
240
*/
249
- function groupMissing ( missing , cwd , consumerPath ) {
250
- const groups = byPathType ( missing ) ;
241
+ function groupMissing ( missing , cwd , consumerPath , bindingPrefix ) {
242
+ /**
243
+ * Group missing dependencies by types (files, bits, packages)
244
+ * @param {Array } missing list of missing paths to group
245
+ * @returns {Function } function which group the dependencies
246
+ */
247
+ const byPathType = R . groupBy ( ( missing ) => {
248
+ return missing . startsWith ( `${ bindingPrefix } /` ) ? 'bits' :
249
+ missing . startsWith ( '.' ) ? 'files' :
250
+ 'packages' ;
251
+ } ) ;
252
+ const groups = byPathType ( missing , bindingPrefix ) ;
251
253
const packages = groups . packages ? groups . packages . map ( resolvePackageNameByPath ) : [ ] ;
252
254
// This is a hack to solve problems that madge has with packages for type script files
253
255
// It see them as missing even if they are exists
@@ -370,7 +372,7 @@ export default async function getDependencyTree(baseDir: string, consumerPath: s
370
372
Promise < { missing: Object , tree : Tree } > {
371
373
const config = { baseDir, includeNpm : true , requireConfig : null , webpackConfig : null , visited : { } , nonExistent : [ ] } ;
372
374
const result = generateTree ( filePaths , config ) ;
373
- const { groups, foundPackages } = groupMissing ( result . skipped , baseDir , consumerPath ) ;
375
+ const { groups, foundPackages } = groupMissing ( result . skipped , baseDir , consumerPath , bindingPrefix ) ;
374
376
const tree : Tree = groupDependencyTree ( result . tree , baseDir , bindingPrefix ) ;
375
377
const relativeFilePaths = filePaths . map ( filePath => path . relative ( baseDir , filePath ) ) ;
376
378
// Merge manually found packages with madge founded packages
0 commit comments