From 16e15f50d2e7769c153f3e6cf07f57e2dc8054c5 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 31 Jan 2020 21:07:59 +0000 Subject: [PATCH] refactor(ngcc): export magic strings as constants (#35079) These strings will be used when cleaning up outdated packages. PR Close #35079 --- .../compiler-cli/ngcc/src/writing/in_place_file_writer.ts | 3 ++- .../ngcc/src/writing/new_entry_point_file_writer.ts | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/writing/in_place_file_writer.ts b/packages/compiler-cli/ngcc/src/writing/in_place_file_writer.ts index 118f256fed..8619b49c57 100644 --- a/packages/compiler-cli/ngcc/src/writing/in_place_file_writer.ts +++ b/packages/compiler-cli/ngcc/src/writing/in_place_file_writer.ts @@ -12,6 +12,7 @@ import {EntryPointBundle} from '../packages/entry_point_bundle'; import {FileToWrite} from '../rendering/utils'; import {FileWriter} from './file_writer'; +export const NGCC_BACKUP_EXTENSION = '.__ivy_ngcc_bak'; /** * This FileWriter overwrites the transformed file, in-place, while creating * a back-up of the original file with an extra `.__ivy_ngcc_bak` extension. @@ -27,7 +28,7 @@ export class InPlaceFileWriter implements FileWriter { protected writeFileAndBackup(file: FileToWrite): void { this.fs.ensureDir(dirname(file.path)); - const backPath = absoluteFrom(`${file.path}.__ivy_ngcc_bak`); + const backPath = absoluteFrom(`${file.path}${NGCC_BACKUP_EXTENSION}`); if (this.fs.exists(backPath)) { throw new Error( `Tried to overwrite ${backPath} with an ngcc back up file, which is disallowed.`); diff --git a/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts b/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts index 3a48256a2a..2c9b0570c8 100644 --- a/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts +++ b/packages/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.ts @@ -15,7 +15,8 @@ import {FileToWrite} from '../rendering/utils'; import {InPlaceFileWriter} from './in_place_file_writer'; import {PackageJsonUpdater} from './package_json_updater'; -const NGCC_DIRECTORY = '__ivy_ngcc__'; +export const NGCC_DIRECTORY = '__ivy_ngcc__'; +export const NGCC_PROPERTY_EXTENSION = '_ivy_ngcc'; /** * This FileWriter creates a copy of the original entry-point, then writes the transformed @@ -93,7 +94,8 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter { `(${formatProperties.join(', ')}) map to more than one format-path.`); } - update.addChange([`${formatProperty}_ivy_ngcc`], newFormatPath, {before: formatProperty}); + update.addChange( + [`${formatProperty}${NGCC_PROPERTY_EXTENSION}`], newFormatPath, {before: formatProperty}); } update.writeChanges(packageJsonPath, packageJson);