Skip to content

Commit

Permalink
fix: config file removed before watcher started (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
L2jLiga authored Sep 29, 2024
1 parent 9dc6976 commit fbe0137
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ jobs:
- name: Test
run: npm test
- name: Integration Tests
if: matrix.os == 'ubuntu-latest'
run: npm run test:integration
7 changes: 4 additions & 3 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ export async function launchDaemon(resolver, hash) {
*/
export async function stopDaemon(resolver, config) {
try {
await platformAwareStopDaemon(config);
await Promise.all([
waitForConfig(resolver.base),
platformAwareStopDaemon(config)
]);
} catch (err) {
console.error(`eslint_d: ${err} - removing config`);
await removeConfig(resolver);
return;
}
await waitForConfig(resolver.base);
}

/**
Expand Down
14 changes: 8 additions & 6 deletions lib/launcher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,11 @@ describe('lib/launcher', () => {
assert.calledOnceWith(fs_promises.unlink, `${resolver.base}/.eslint_d`);
});

it('does not watch for the config file', () => {
stopDaemon(resolver, config);
it('does not wait for the config file removal', async () => {
const promise = stopDaemon(resolver, config);

refute.called(fs.watch);
assert.calledOnceWith(fs.watch, resolver.base);
await assert.resolves(promise, undefined);
});
});
});
Expand Down Expand Up @@ -339,10 +340,11 @@ describe('lib/launcher', () => {
assert.calledOnceWith(fs_promises.unlink, `${resolver.base}/.eslint_d`);
});

it('does not watch for the config file', () => {
stopDaemon(resolver, config);
it('does not wait for the config file removal', async () => {
const promise = stopDaemon(resolver, config);

refute.called(fs.watch);
assert.calledOnceWith(fs.watch, resolver.base);
await assert.resolves(promise, undefined);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"scripts": {
"lint": "eslint .",
"test": "mocha '**/*.test.js'",
"test:integration": "mocha --bail --slow 1000 test/test.integration.js",
"test:integration": "mocha --bail --slow 1000 --timeout 5000 test/test.integration.js",
"test:coverage": "mcr --filter \"{'**/node_modules/**':false,'**/**':true}\" -r v8,console-details mocha '**/*.test.js'",
"watch": "chokidar '**/*.js' -c 'npm t' --initial --silent",
"prepare": "husky && sh scripts/install-fixture-deps.sh",
Expand Down

0 comments on commit fbe0137

Please sign in to comment.