Skip to content

Commit

Permalink
fix(compas): debounce persist cache, fix package-manager comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkdev98 committed Sep 1, 2023
1 parent 6bb4bbd commit 1c05783
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/compas/src/main/ci/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ export function ciMode(env) {
message: "TODO: a future update will do more things...",
});

// TODO: load project

// TODO: resolve root directories

// TODO: for each root directory execute inferredLintCommand

return Promise.resolve();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export class CacheCleanupIntegration extends BaseIntegration {
async init() {
await super.init();

await this.cleanup();

const hasPreviouslyCleaned = this.state.cache.cachesCleaned;
this.state.cache.cachesCleaned = true;
await this.state.emitCacheUpdated();

if (!hasPreviouslyCleaned) {
return await this.state.emitCacheUpdated();
}
}

async onConfigUpdated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PackageManagerIntegration extends BaseIntegration {
Object.keys(existingMapping).length !== Object.keys(newMapping).length;

for (const key of Object.keys(existingMapping)) {
if (existingMapping[key] !== newMapping[key]) {
if (existingMapping[key]?.join(" ") !== newMapping[key]?.join(" ")) {
hasDiff = true;
}

Expand Down
10 changes: 9 additions & 1 deletion packages/compas/src/main/development/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,15 @@ export class State {
async emitCacheUpdated() {
debugPrint(`State#emitCacheUpdated`);

await cachePersist(this.cache);
if (!this.cachePersistTimer) {
const _self = this;
this.cachePersistTimer = setTimeout(() => {
debugPrint("State#emitCacheUpdated :: Running cachePersist");
cachePersist(_self.cache);
}, 50);
} else {
this.cachePersistTimer.refresh();
}

for (const integration of this.integrations) {
await integration.onCacheUpdated();
Expand Down

0 comments on commit 1c05783

Please sign in to comment.