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

chore(deps): update dependency eslint-plugin-perfectionist to v4 #215

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
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
74 changes: 16 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"cspell": "8.16.0",
"eslint": "9.15.0",
"eslint-plugin-n": "17.14.0",
"eslint-plugin-perfectionist": "3.9.1",
"eslint-plugin-perfectionist": "4.0.3",
"husky": "9.1.7",
"knip": "5.37.2",
"lint-staged": "15.2.10",
Expand Down
8 changes: 4 additions & 4 deletions src/impvol-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ function guessFormat(specifier: string): ModuleFormat | undefined {
}
}

function shouldReload(): boolean {
return Atomics.load(uint8, 0) !== 0;
}

function reload() {
const buffer = readFileSync(tmp);
const cbor = new Uint8Array(buffer);
Expand All @@ -85,6 +81,10 @@ function reload() {
debug('Reloaded snapshot from %s', tmp);
}

function shouldReload(): boolean {
return Atomics.load(uint8, 0) !== 0;
}

export const resolve: ResolveHook = (specifier, context, nextResolve) => {
const start = performance.now();
if (shouldReload()) {
Expand Down
42 changes: 21 additions & 21 deletions src/impvol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,6 @@ const metadata = new WeakMap<
}
>();

/**
* Updates the snapshot of the {@link ImportableVolume}.
*
* It writes to the temp file associated with the `ImportableVolume`, then sets
* the dirty bit.
*
* @param impvol {@link ImportableVolume} to snapshot
* @throws {ReferenceError} If metadata is missing
* @internal
*/
function update(impvol: ImportableVolume): void {
const snapshot = toBinarySnapshotSync({fs: impvol});
const {tmp, uint8} = metadata.get(impvol)!;
if (!tmp || !uint8) {
throw new ReferenceError('Missing metadata');
}
writeFileSync(tmp, snapshot);
Atomics.store(uint8, 0, 1);
debug('Updated snapshot');
}

export class ImportableVolume extends Volume {
constructor(props?: {File?: File; Link?: Link; Node?: Node}) {
super(props);
Expand Down Expand Up @@ -121,6 +100,27 @@ export class ImportableVolume extends Volume {
}
}

/**
* Updates the snapshot of the {@link ImportableVolume}.
*
* It writes to the temp file associated with the `ImportableVolume`, then sets
* the dirty bit.
*
* @param impvol {@link ImportableVolume} to snapshot
* @throws {ReferenceError} If metadata is missing
* @internal
*/
function update(impvol: ImportableVolume): void {
const snapshot = toBinarySnapshotSync({fs: impvol});
const {tmp, uint8} = metadata.get(impvol)!;
if (!tmp || !uint8) {
throw new ReferenceError('Missing metadata');
}
writeFileSync(tmp, snapshot);
Atomics.store(uint8, 0, 1);
debug('Updated snapshot');
}

// overrides private methods such that meaningful filesystem writes trigger an
// update on the worker thread. Note that using a `FSWatcher` was attempted, but
// memfs' implementation is probably Wrong; the change/rename events are emitted
Expand Down