Skip to content

Commit 6372f29

Browse files
hanslBrocco
authored andcommitted
fix(@angular/cli): if user pass a full path, use the path (#6341)
1 parent f143cb6 commit 6372f29

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/@angular/cli/utilities/find-parent-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function findParentModule(
2626
if (files.length === 1) {
2727
return path.join(pathToCheck, files[0]);
2828
} else if (files.length > 1) {
29-
throw new SilentError(`Multiple module files found: ${pathToCheck.replace(sourceRoot, '')}`);
29+
throw new SilentError(`Multiple module files found: ${JSON.stringify(files)}`);
3030
}
3131

3232
// move to parent directory

packages/@angular/cli/utilities/resolve-module-file.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ export function resolveModulePath(
77
let baseModuleName = moduleNameFromFlag;
88
let parentFolders = '';
99

10+
// If it's a full path from the cwd, we use it as is.
11+
if (fs.existsSync(moduleNameFromFlag) && fs.statSync(moduleNameFromFlag).isFile()) {
12+
return path.resolve(moduleNameFromFlag);
13+
}
14+
1015
if (baseModuleName.includes(path.sep)) {
1116
const splitPath = baseModuleName.split(path.sep);
1217
baseModuleName = splitPath.pop();
1318
parentFolders = splitPath.join(path.sep);
1419
}
1520

1621
if (baseModuleName.includes('.')) {
17-
baseModuleName = baseModuleName
18-
.split('.')
19-
.filter(part => part !== 'module' && part !== 'ts')
20-
.join('.');
22+
baseModuleName = baseModuleName.replace(/(\.module)?(\.ts)?$/, '');
2123
}
2224

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

0 commit comments

Comments
 (0)