Skip to content

Commit

Permalink
fix(Schematics): correct resolution of environments path for module (#…
Browse files Browse the repository at this point in the history
…1094)

Closes #1090
  • Loading branch information
timdeschryver authored and brandonroberts committed May 25, 2018
1 parent 214e4a6 commit d24ed10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions modules/schematics/src/store/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Store Schematic', () => {
);
const defaultOptions: StoreOptions = {
name: 'foo',
// path: 'app',
project: 'bar',
spec: true,
module: undefined,
Expand Down Expand Up @@ -63,7 +62,17 @@ describe('Store Schematic', () => {
);
});

it('should import the environments correctly', () => {
it('should import the environments correctly in the app module', () => {
const options = { ...defaultOptions, module: 'app.module.ts' };

const tree = schematicRunner.runSchematic('store', options, appTree);
const content = tree.readContent(`${projectPath}/src/app/app.module.ts`);
expect(content).toMatch(
/import { environment } from '..\/environments\/environment';/
);
});

it('should import the environments correctly in the reducers', () => {
const options = { ...defaultOptions, module: 'app.module.ts' };

const tree = schematicRunner.runSchematic('store', options, appTree);
Expand Down
4 changes: 2 additions & 2 deletions modules/schematics/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ function addImportToNgModule(options: StoreOptions): Rule {

const statePath = `${options.path}/${options.statePath}`;
const relativePath = buildRelativePath(modulePath, statePath);
const srcPath = dirname(options.path as Path);

const environmentsPath = buildRelativePath(
statePath,
`${srcPath}/environments/environment`
`${options.path}/environments/environment`
);

const storeNgModuleImport = addImportToModule(
Expand Down

0 comments on commit d24ed10

Please sign in to comment.