Skip to content

fix(@angular/cli): if user pass a full path, use the path #6341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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