Skip to content
Merged
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
10 changes: 7 additions & 3 deletions ng-dev/release/snapshot-publish/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ interface SnapshotRepo {
containsChanges: boolean;
}

/**
* Paths to exclude from the snapshot commit.
*/
const PATHS_TO_EXCLUDE = ['**/MODULE.bazel.lock', '**/package-lock.json', '**/pubspec.lock'];

export class SnapshotPublisher {
Comment on lines +34 to 39
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better encapsulation, consider moving PATHS_TO_EXCLUDE inside the SnapshotPublisher class as a private static readonly property. This constant is only used within this class, so this change would improve cohesion.

export class SnapshotPublisher {
  /**
   * Paths to exclude from the snapshot commit.
   */
  private static readonly PATHS_TO_EXCLUDE = ['**/MODULE.bazel.lock', '**/package-lock.json', '**/pubspec.lock'];

/** The current branch name. */
readonly branchName = this.git.getCurrentBranchOrRevision();
Expand Down Expand Up @@ -152,7 +157,7 @@ export class SnapshotPublisher {
.stdout.trim()
.split('\n')
.filter((filePath) => filePath !== '')
.map((filePath: string) => rm(join(tmpRepoDir, filePath), {force: true})),
.map((filePath) => rm(join(tmpRepoDir, filePath), {force: true})),
);
cpSync(pkg.outputPath, tmpRepoDir, {recursive: true});
this.git.run(['add', '-A'], {cwd: tmpRepoDir});
Expand All @@ -166,8 +171,7 @@ export class SnapshotPublisher {
'HEAD',
'--',
'.',
':(exclude)**/MODULE.bazel.lock',
':(exclude)**/package-lock.json',
...PATHS_TO_EXCLUDE.map((p) => `:(exclude)${p}`),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with moving PATHS_TO_EXCLUDE into the SnapshotPublisher class, please update its usage here to reference it as a static property.

              ...SnapshotPublisher.PATHS_TO_EXCLUDE.map((p) => `:(exclude)${p}`),

],
{cwd: tmpRepoDir},
).status === 1;
Expand Down
Loading