Skip to content

Commit

Permalink
method to return actual flag value
Browse files Browse the repository at this point in the history
  • Loading branch information
pancaspe87 committed Feb 21, 2025
1 parent d8bbec9 commit e7a2eaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions packages/core/feature-flags/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ export function getFeatureFlag(flagName: $Keys<FeatureFlags>): boolean {
return value === true || value === 'NEW';
}

export function getFeatureFlagValue(
flagName: $Keys<FeatureFlags>,
): boolean | string | number {
return featureFlagValues[flagName];
}

export type DiffResult<CustomDiagnostic> = {|
isDifferent: boolean,
custom: CustomDiagnostic,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/fs/src/NodeVCSAwareFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {FilePath} from '@atlaspack/types-internal';
import type {Event, Options as WatcherOptions} from '@parcel/watcher';
import {registerSerializableClass} from '@atlaspack/build-cache';
import {instrument, instrumentAsync} from '@atlaspack/logger';
import {getFeatureFlag} from '@atlaspack/feature-flags';
import {getFeatureFlagValue} from '@atlaspack/feature-flags';

// $FlowFixMe
import packageJSON from '../package.json';
Expand Down Expand Up @@ -45,15 +45,15 @@ export class NodeVCSAwareFS extends NodeFS {
type: e.changeType,
}));

if (getFeatureFlag('vcsMode') !== 'NEW') {
if (getFeatureFlagValue('vcsMode') !== 'NEW') {
watcherEventsSince = await instrumentAsync(
'NodeVCSAwareFS::watchman.getEventsSince',
() => this.watcher().getEventsSince(dir, nativeSnapshotPath, opts),
);
this.#options.logEventDiff(watcherEventsSince, vcsEventsSince);
}

if (['NEW_AND_CHECK', 'NEW'].includes(getFeatureFlag('vcsMode'))) {
if (['NEW_AND_CHECK', 'NEW'].includes(getFeatureFlagValue('vcsMode'))) {
return vcsEventsSince;
}

Expand All @@ -71,7 +71,7 @@ export class NodeVCSAwareFS extends NodeFS {
snapshotDirectory,
`${filename}.native-snapshot.txt`,
);
if (getFeatureFlag('vcsMode') !== 'NEW') {
if (getFeatureFlagValue('vcsMode') !== 'NEW') {
await this.watcher().writeSnapshot(dir, nativeSnapshotPath, opts);
}

Expand Down

0 comments on commit e7a2eaf

Please sign in to comment.