Skip to content

Commit

Permalink
fix(@schematics/angular): added webWorkerTsConfig into test option
Browse files Browse the repository at this point in the history
(cherry picked from commit 052b8fa)
  • Loading branch information
InSantoshMahto authored and alan-agius4 committed Jun 7, 2021
1 parent a234c66 commit b867066
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/schematics/angular/web-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ function addSnippet(options: WebWorkerOptions): Rule {
export default function (options: WebWorkerOptions): Rule {
return async (host: Tree) => {
const workspace = await getWorkspace(host);

if (!options.project) {
throw new SchematicsException('Option "project" is required.');
}
Expand Down Expand Up @@ -142,6 +141,18 @@ export default function (options: WebWorkerOptions): Rule {
projectTargetOptions.webWorkerTsConfig = workerConfigPath;
}

const projectTestTarget = project.targets.get('test');
if (projectTestTarget) {
const projectTestTargetOptions = ((projectTestTarget.options ||
{}) as unknown) as BrowserBuilderOptions;

const needWebWorkerConfig = !projectTestTargetOptions.webWorkerTsConfig;
if (needWebWorkerConfig) {
const workerConfigPath = join(normalize(root), 'tsconfig.worker.json');
projectTestTargetOptions.webWorkerTsConfig = workerConfigPath;
}
}

const templateSource = apply(url('./files/worker'), [
applyTemplates({ ...options, ...strings }),
move(parsedPath.path),
Expand Down

0 comments on commit b867066

Please sign in to comment.