Skip to content

Commit

Permalink
fix: assure in add/update schematics only new buildTarget is used
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sc committed Feb 22, 2024
1 parent d902a64 commit 114173c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions schematics/migrations/2_0_0/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Rule, SchematicContext, SchematicsException, Tree} from '@angular-devkit/schematics';
import {updateWorkspace} from '@schematics/angular/utility/workspace';
import {buildTargetAttribute} from '../../../src/buildTargetAttribute';

function updateNpmScript(tree: Tree, logger: SchematicContext['logger']) {
const pkgPath = '/package.json';
Expand Down Expand Up @@ -33,8 +32,9 @@ export default function (): Rule {
i18nTarget.builder = 'ng-extract-i18n-merge:ng-extract-i18n-merge';
i18nTarget.options = {
...i18nMergeTarget.options,
[buildTargetAttribute]: i18nTarget.options?.browserTarget ?? i18nTarget.options?.buildTarget ?? `${projectName}:build`
buildTarget: i18nTarget.options?.browserTarget ?? i18nTarget.options?.buildTarget ?? `${projectName}:build`
}
delete i18nTarget.options.browserTarget;
project.targets.delete('extract-i18n'); // 'project.targets.set' not working!?
project.targets.add({name: 'extract-i18n', ...i18nTarget});
project.targets.delete('extract-i18n-merge');
Expand Down
3 changes: 1 addition & 2 deletions schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {Schema} from './schema';
import {JsonArray, JsonObject, normalize, Path, relative} from '@angular-devkit/core';

import {Options} from '../../src/options';
import {buildTargetAttribute} from '../../src/buildTargetAttribute';

function getTargetFiles(i18nExtension: JsonObject | undefined): string[] {
const locales = i18nExtension?.locales ? (Object.values(i18nExtension?.locales) as JsonArray | string[] | undefined) : undefined;
Expand Down Expand Up @@ -95,7 +94,7 @@ export function ngAdd(_options: Schema): Rule {

const target = projectWorkspace.targets.get('extract-i18n');
const builderOptions: Partial<Options> = {
[buildTargetAttribute]: buildTarget,
buildTarget: buildTarget,
format,
outputPath,
targetFiles: filesWithoutOutputPath ?? []
Expand Down

0 comments on commit 114173c

Please sign in to comment.