Skip to content

Commit

Permalink
refactor(ngcc): export magic strings as constants (#35079)
Browse files Browse the repository at this point in the history
These strings will be used when cleaning up outdated
packages.

PR Close #35079
  • Loading branch information
petebacondarwin authored and mhevery committed Feb 1, 2020
1 parent 093ac39 commit f12f840
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Expand Up @@ -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.
Expand All @@ -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.`);
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f12f840

Please sign in to comment.