fix(devkit): devkitTreeFromAngularDevkitTree exists function should also work on dirs

ISSUES CLOSED: #5318
This commit is contained in:
Juri 2021-04-14 10:13:47 +02:00 committed by Victor Savkin
parent 2c76dbe5e7
commit 0f08149021
2 changed files with 41 additions and 1 deletions

View File

@ -17,6 +17,42 @@ describe('Storybook schematics', () => {
afterEach(() => removeProject({ onlyOnCI: true }));
it('aaashould not overwrite global storybook config files', () => {
const angularStorybookLib = uniq('test-ui-lib-angular');
runCLI(
`generate @nrwl/angular:lib ${angularStorybookLib} --no-interactive`
);
runCLI(
`generate @nrwl/angular:storybook-configuration ${angularStorybookLib} --generateStories --no-interactive`
);
checkFilesExist(`.storybook/main.js`);
writeFileSync(
tmpProjPath(`.storybook/main.js`),
`
module.exports = {
stories: [],
addons: ['@storybook/addon-knobs/register'],
};
console.log('hi there');
`
);
// generate another lib with storybook config
const anotherAngularStorybookLib = uniq('test-ui-lib-angular2');
runCLI(
`generate @nrwl/angular:lib ${anotherAngularStorybookLib} --no-interactive`
);
runCLI(
`generate @nrwl/angular:storybook-configuration ${anotherAngularStorybookLib} --generateStories --no-interactive`
);
expect(readFile(`.storybook/main.js`)).toContain(
`console.log('hi there');`
);
});
describe('build storybook', () => {
it('should execute e2e tests using Cypress running against Storybook', () => {
const myapp = uniq('myapp');

View File

@ -86,7 +86,11 @@ class DevkitTreeFromAngularDevkitTree {
}
exists(filePath: string): boolean {
return this.tree.exists(filePath);
if (this.isFile(filePath)) {
return this.tree.exists(filePath);
} else {
return this.children(filePath).length > 0;
}
}
isFile(filePath: string): boolean {