Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
fix: respect log level for cache clear (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
calebboyd authored and nchanged committed Sep 28, 2017
1 parent 9b69892 commit 2d8131f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/CacheBreaker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Config } from "./Config";
import * as path from "path";
import { fastHash, removeFolder, ensureDir } from "./Utils";
import * as fs from "fs";
import * as log from "fliplog";
import { Log } from "./Log";
/**
*
* The only purpose of this ugly function is to break cache when user changes the config..
Expand All @@ -21,8 +21,7 @@ export function breakCache() {
if (fs.existsSync(infoFile)) {
const lastModifiedStored = fs.readFileSync(infoFile).toString();
if (fileModificationTime.toString() !== lastModifiedStored) {
log.white(``).echo();
log.white(`-- cache cleared ---`).echo();
Log.defer((log) => log.echoGray(`--- cache cleared ---`));
removeFolder(Config.TEMP_FOLDER);
fs.writeFileSync(infoFile, fileModificationTime.toString());
}
Expand Down
14 changes: 12 additions & 2 deletions src/Log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export class Log {
public spinner: any;
public indent: Indenter = new Indenter();
private totalSize = 0;
private static deferred: Function[] = [];
public static defer (fn: Function) {
Log.deferred.push(fn)
}

constructor(public context: WorkFlowContext) {
this.printLog = context.doLog;
Expand Down Expand Up @@ -97,9 +101,15 @@ export class Log {

// if not false and conditions pass, log it
return null;
});;
}
});

setTimeout(() => {
if (this.printLog) {
Log.deferred.forEach(x => x(this))
}
Log.deferred = []
})
}
// --- config ---

public reset(): Log {
Expand Down

0 comments on commit 2d8131f

Please sign in to comment.