Skip to content

Commit 1c05783

Browse files
committed
fix(compas): debounce persist cache, fix package-manager comparison
1 parent 6bb4bbd commit 1c05783

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

packages/compas/src/main/ci/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ export function ciMode(env) {
2828
message: "TODO: a future update will do more things...",
2929
});
3030

31+
// TODO: load project
32+
33+
// TODO: resolve root directories
34+
35+
// TODO: for each root directory execute inferredLintCommand
36+
3137
return Promise.resolve();
3238
}

packages/compas/src/main/development/integrations/cache-cleanup.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export class CacheCleanupIntegration extends BaseIntegration {
1111
async init() {
1212
await super.init();
1313

14-
await this.cleanup();
15-
14+
const hasPreviouslyCleaned = this.state.cache.cachesCleaned;
1615
this.state.cache.cachesCleaned = true;
17-
await this.state.emitCacheUpdated();
16+
17+
if (!hasPreviouslyCleaned) {
18+
return await this.state.emitCacheUpdated();
19+
}
1820
}
1921

2022
async onConfigUpdated() {

packages/compas/src/main/development/integrations/package-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class PackageManagerIntegration extends BaseIntegration {
8282
Object.keys(existingMapping).length !== Object.keys(newMapping).length;
8383

8484
for (const key of Object.keys(existingMapping)) {
85-
if (existingMapping[key] !== newMapping[key]) {
85+
if (existingMapping[key]?.join(" ") !== newMapping[key]?.join(" ")) {
8686
hasDiff = true;
8787
}
8888

packages/compas/src/main/development/state.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,15 @@ export class State {
220220
async emitCacheUpdated() {
221221
debugPrint(`State#emitCacheUpdated`);
222222

223-
await cachePersist(this.cache);
223+
if (!this.cachePersistTimer) {
224+
const _self = this;
225+
this.cachePersistTimer = setTimeout(() => {
226+
debugPrint("State#emitCacheUpdated :: Running cachePersist");
227+
cachePersist(_self.cache);
228+
}, 50);
229+
} else {
230+
this.cachePersistTimer.refresh();
231+
}
224232

225233
for (const integration of this.integrations) {
226234
await integration.onCacheUpdated();

0 commit comments

Comments
 (0)