fix: dep paths for windows

This commit is contained in:
Bogdan Lyashenko
2019-02-12 19:21:23 +01:00
parent 95651a9d12
commit 3d581e6ed2
4 changed files with 16 additions and 8 deletions

View File

@@ -41,21 +41,24 @@ const getImports = (fileCode, itemPath) => {
const getDependencies = (entryPoint, projectDir, webpackConfigPath) => {
const rootPath = path.resolve();
const separator = path.sep;
return madge(entryPoint, {
webpackConfig: webpackConfigPath,
baseDir: projectDir,
// TODO: this filter will be extended based on how much dependencies is needed
dependencyFilter: (depPath, sourcePath) => sourcePath === `${rootPath}/${entryPoint}`
dependencyFilter: (depPath, sourcePath) => sourcePath === `${rootPath}${separator}${entryPoint}`
})
.then(res => res.obj())
.then(obj =>
Object.entries(obj).reduce((tree, [key, value]) => {
const moduleName = `${projectDir}/${key}`;
const moduleName = `${projectDir}${separator}${key.replace(/\//g, separator)}`;
tree[moduleName] = {
moduleName,
importedModuleNames: value.map(v => `${projectDir}/${v}`)
importedModuleNames: value.map(
v => `${projectDir}${separator}${v.replace(/\//g, separator)}`
)
};
return tree;