Skip to content

Commit 7d51b6d

Browse files
committed
bug(generate): fix relative path module generations
1 parent a431389 commit 7d51b6d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

packages/angular-cli/blueprints/module/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
},
5959

6060
afterInstall: function (options) {
61-
options.entity.name = path.relative(this.dynamicPath.appRoot, this.generatePath);
61+
options.entity.name = this.entityName;
6262
options.flat = false;
6363
options.route = false;
6464
options.inlineTemplate = false;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {join} from 'path';
2+
import {ng} from '../../../utils/process';
3+
import {expectFileToExist, createDir} from '../../../utils/fs';
4+
import {expectToFail} from '../../../utils/utils';
5+
6+
7+
export default function() {
8+
const moduleDir = join('src', 'app', 'test-module');
9+
10+
11+
return Promise.resolve()
12+
.then(() => createDir('src/app/fldr'))
13+
.then(() => process.chdir('./src/app/fldr'))
14+
.then(() => process.env.PWD = process.cwd()))
15+
.then(() => ng('generate', 'module', '../test-module'))
16+
.then(() => expectFileToExist(moduleDir))
17+
.then(() => expectFileToExist(join(moduleDir, 'test-module.module.ts')))
18+
.then(() => expectToFail(() => expectFileToExist(join(moduleDir, 'test-module.routing.ts'))))
19+
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.ts')))
20+
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.spec.ts')))
21+
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.html')))
22+
.then(() => expectFileToExist(join(moduleDir, 'test-module.component.css')))
23+
24+
// Try to run the unit tests.
25+
.then(() => ng('test', '--single-run'));
26+
}

tests/e2e_runner.js

+7
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ testsToRun.reduce((previous, relativeName) => {
9191
throw new Error('Invalid test module.');
9292
};
9393

94+
let currentDir = null;
9495
let clean = true;
9596
return Promise.resolve()
9697
.then(() => printHeader(currentFileName))
98+
.then(() => currentDir = process.cwd())
9799
.then(() => fn(argv, () => clean = false))
98100
.then(() => console.log(' ----'))
99101
.then(() => {
@@ -103,6 +105,11 @@ testsToRun.reduce((previous, relativeName) => {
103105
return gitClean();
104106
}
105107
})
108+
.then(() => {
109+
if (allSetups.indexOf(relativeName) == -1) {
110+
process.chdir(currentDir);
111+
}
112+
})
106113
.then(() => printFooter(currentFileName, start),
107114
(err) => {
108115
printFooter(currentFileName, start);

0 commit comments

Comments
 (0)