Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional fixes after testing in product #328

Closed
wants to merge 1 commit into from
Closed
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
21 changes: 18 additions & 3 deletions packages/core/fs/src/NodeVCSAwareFS.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ import {NodeFS} from './NodeFS';
import {getVcsStateSnapshot, getEventsSince} from '@atlaspack/rust';
import type {FilePath} from '@atlaspack/types-internal';
import type {Event, Options as WatcherOptions} from '@parcel/watcher';
import type {BuildSuccessEvent} from '@atlaspack/types';
import {registerSerializableClass} from '@atlaspack/build-cache';

// $FlowFixMe
import packageJSON from '../package.json';

interface VcsOptions extends WatcherOptions {
event?: BuildSuccessEvent;
}

export interface NodeVCSAwareFSOptions {
gitRepoPath: FilePath;
excludePatterns: Array<string>;
logEventDiff: (watcherEvents: Event[], vcsEvents: string[]) => void;
logEventDiff: (
watcherEvents: Event[],
vcsEvents: string[],
event: BuildSuccessEvent,
) => void;
}

export class NodeVCSAwareFS extends NodeFS {
Expand All @@ -27,7 +36,7 @@ export class NodeVCSAwareFS extends NodeFS {
async getEventsSince(
dir: FilePath,
snapshot: FilePath,
opts: WatcherOptions,
opts: VcsOptions,
): Promise<Array<Event>> {
// Note: can't use toString() directly, or it won't resolve the promise
const snapshotFile = await this.readFile(snapshot);
Expand All @@ -43,7 +52,13 @@ export class NodeVCSAwareFS extends NodeFS {
this.#options.gitRepoPath,
vcsState.gitHash,
);
this.#options.logEventDiff(watcherEventsSince, vcsEventsSince);
if (opts.event) {
this.#options.logEventDiff(
watcherEventsSince,
vcsEventsSince,
opts.event,
);
}

return watcherEventsSince;
}
Expand Down