Skip to content

Commit d24ed10

Browse files
timdeschryverbrandonroberts
authored andcommitted
fix(Schematics): correct resolution of environments path for module (#1094)
Closes #1090
1 parent 214e4a6 commit d24ed10

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

modules/schematics/src/store/index.spec.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ describe('Store Schematic', () => {
1717
);
1818
const defaultOptions: StoreOptions = {
1919
name: 'foo',
20-
// path: 'app',
2120
project: 'bar',
2221
spec: true,
2322
module: undefined,
@@ -63,7 +62,17 @@ describe('Store Schematic', () => {
6362
);
6463
});
6564

66-
it('should import the environments correctly', () => {
65+
it('should import the environments correctly in the app module', () => {
66+
const options = { ...defaultOptions, module: 'app.module.ts' };
67+
68+
const tree = schematicRunner.runSchematic('store', options, appTree);
69+
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
70+
expect(content).toMatch(
71+
/import { environment } from '..\/environments\/environment';/
72+
);
73+
});
74+
75+
it('should import the environments correctly in the reducers', () => {
6776
const options = { ...defaultOptions, module: 'app.module.ts' };
6877

6978
const tree = schematicRunner.runSchematic('store', options, appTree);

modules/schematics/src/store/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ function addImportToNgModule(options: StoreOptions): Rule {
5454

5555
const statePath = `${options.path}/${options.statePath}`;
5656
const relativePath = buildRelativePath(modulePath, statePath);
57-
const srcPath = dirname(options.path as Path);
57+
5858
const environmentsPath = buildRelativePath(
5959
statePath,
60-
`${srcPath}/environments/environment`
60+
`${options.path}/environments/environment`
6161
);
6262

6363
const storeNgModuleImport = addImportToModule(

0 commit comments

Comments
 (0)