Skip to content

Commit

Permalink
fix(schematics): check type of tsConfig lint entry (ng-add)
Browse files Browse the repository at this point in the history
  • Loading branch information
skydever authored and vsavkin committed Oct 22, 2018
1 parent 12e4842 commit cd43c6d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
25 changes: 25 additions & 0 deletions e2e/schematics/ng-add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,31 @@ describe('Nrwl Convert to Nx Workspace', () => {
);
});

it('should handle type array at tslint builder options.tsConfig (e2e project)', () => {
// create a new AngularCLI app
runNgNew();

// set array at tslint builder options.tsConfig
const existingAngularJson = readJson('angular.json');
existingAngularJson.projects['proj-e2e'].architect.lint.options.tsConfig = [
'e2e/tsconfig.e2e.json'
];
updateFile('angular.json', JSON.stringify(existingAngularJson, null, 2));

// Add @nrwl/schematics
runCLI('add @nrwl/schematics --npmScope projscope --skip-install');

const updatedAngularCLIJson = readJson('angular.json');

expect(updatedAngularCLIJson.projects['proj-e2e'].architect.lint).toEqual({
builder: '@angular-devkit/build-angular:tslint',
options: {
tsConfig: ['apps/proj-e2e/tsconfig.e2e.json'],
exclude: ['**/node_modules/**']
}
});
});

it('should handle different types of errors', () => {
// create a new AngularCLI app
runNgNew();
Expand Down
14 changes: 10 additions & 4 deletions packages/schematics/src/collection/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,16 @@ function updateAngularCLIJson(options: Schema): Rule {
);

const e2eLintConfig = e2eProject.architect.lint;
e2eLintConfig.options.tsConfig = path.join(
e2eProject.root,
getFilename(e2eLintConfig.options.tsConfig)
);
e2eLintConfig.options.tsConfig = Array.isArray(
e2eLintConfig.options.tsConfig
)
? e2eLintConfig.options.tsConfig.map(tsConfigPath =>
path.join(e2eProject.root, getFilename(tsConfigPath))
)
: path.join(
e2eProject.root,
getFilename(e2eLintConfig.options.tsConfig)
);

angularJson.projects[getE2eKey(angularJson)] = e2eProject;
}
Expand Down

0 comments on commit cd43c6d

Please sign in to comment.