Skip to content

Commit

Permalink
refactor(betterer 🔧): make resolver depth customisable (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
phenomnomnominal authored Feb 26, 2021
1 parent 738fe04 commit f75e093
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion goldens/api/@betterer/betterer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export declare type BettererFilePatterns = ReadonlyArray<RegExp | ReadonlyArray<

export declare class BettererFileResolver {
get cwd(): string;
constructor();
constructor(resolverDepth?: number);
excludeΔ(...excludePatterns: BettererFilePatterns): this;
files(filePaths: BettererFilePaths): Promise<BettererFilePaths>;
includeΔ(...includePatterns: BettererFileGlobs): this;
Expand Down
6 changes: 3 additions & 3 deletions packages/betterer/src/test/file-test/file-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export class BettererFileResolver {
private _excluded: Array<RegExp> = [];
private _included: Array<string> = [];

constructor() {
constructor(resolverDepth = 2) {
// In DEBUG mode there is a Proxy that wraps each function call.
// That means that each function call results in two entries in
// the call stack, so we adjust here:
const depth = process.env.BETTERER_DEBUG ? 4 : 2;
resolverDepth = process.env.BETTERER_DEBUG ? resolverDepth * 2 : resolverDepth;

const callStack = stack();
const callee = callStack[depth];
const callee = callStack[resolverDepth];
this._cwd = path.dirname(callee.getFileName());
}

Expand Down

0 comments on commit f75e093

Please sign in to comment.