Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/bazel/src/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ function addDevDependenciesToPackageJson(options: Schema) {
*/
function addFilesRequiredByBazel(options: Schema) {
return (host: Tree) => {
if (!host.exists('yarn.lock')) {
// yarn.lock is required by the yarn_install rule in the WORKSPACE.
host.create('yarn.lock', '');
}
return mergeWith(apply(url('./files'), [
applyTemplates({}),
]));
Expand Down
15 changes: 15 additions & 0 deletions packages/bazel/src/schematics/ng-add/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@ describe('ng-add schematic', () => {
expect(files).not.toContain('/BUILD.bazel');
});

it('should create yarn.lock if it does not exist', () => {
host = schematicRunner.runSchematic('ng-add', defaultOptions, host);
expect(host.files).toContain('/yarn.lock');
expect(host.readContent('/yarn.lock')).toBe('');
});

it('should not overwrite existing yarn.lock', () => {
expect(host.exists('/yarn.lock')).toBe(false);
host.create('/yarn.lock', 'lock file content');
expect(host.files).toContain('/yarn.lock');
host = schematicRunner.runSchematic('ng-add', defaultOptions, host);
expect(host.files).toContain('/yarn.lock');
expect(host.readContent('/yarn.lock')).toBe('lock file content');
});

it('should produce main.dev.ts and main.prod.ts for AOT', () => {
host.create('/src/main.ts', 'generated by CLI');
host = schematicRunner.runSchematic('ng-add', defaultOptions, host);
Expand Down