Skip to content

Commit

Permalink
fix(@angular/cli): if user pass a full path, use the path (#6341)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl authored and Brocco committed May 24, 2017
1 parent f143cb6 commit 6372f29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/@angular/cli/utilities/find-parent-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function findParentModule(
if (files.length === 1) {
return path.join(pathToCheck, files[0]);
} else if (files.length > 1) {
throw new SilentError(`Multiple module files found: ${pathToCheck.replace(sourceRoot, '')}`);
throw new SilentError(`Multiple module files found: ${JSON.stringify(files)}`);
}

// move to parent directory
Expand Down
10 changes: 6 additions & 4 deletions packages/@angular/cli/utilities/resolve-module-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ export function resolveModulePath(
let baseModuleName = moduleNameFromFlag;
let parentFolders = '';

// If it's a full path from the cwd, we use it as is.
if (fs.existsSync(moduleNameFromFlag) && fs.statSync(moduleNameFromFlag).isFile()) {
return path.resolve(moduleNameFromFlag);
}

if (baseModuleName.includes(path.sep)) {
const splitPath = baseModuleName.split(path.sep);
baseModuleName = splitPath.pop();
parentFolders = splitPath.join(path.sep);
}

if (baseModuleName.includes('.')) {
baseModuleName = baseModuleName
.split('.')
.filter(part => part !== 'module' && part !== 'ts')
.join('.');
baseModuleName = baseModuleName.replace(/(\.module)?(\.ts)?$/, '');
}

const baseModuleWithFileSuffix = `${baseModuleName}.module.ts`;
Expand Down

0 comments on commit 6372f29

Please sign in to comment.