Skip to content

Commit

Permalink
Only create the cache directory when needed (#2628)
Browse files Browse the repository at this point in the history
Avoid potential permission issues if we don't use the cache dir anyway,
see <#1128 (comment)>.
  • Loading branch information
novemberborn authored Dec 23, 2020
1 parent 99ab93a commit 3fe4c40
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ class Api extends Emittery {
}
};

let cacheDir;
let testFiles;
try {
cacheDir = this._createCacheDir();
testFiles = await globs.findTests({cwd: this.options.projectDir, ...apiOptions.globs});
if (selectedFiles.length === 0) {
selectedFiles = filter.length === 0 ? testFiles : globs.applyTestFileFilter({
Expand Down Expand Up @@ -189,7 +187,7 @@ class Api extends Emittery {

const {providers = []} = this.options;
const providerStates = (await Promise.all(providers.map(async ({type, main}) => {
const state = await main.compile({cacheDir, files: testFiles});
const state = await main.compile({cacheDir: this._createCacheDir(), files: testFiles});
return state === null ? null : {type, state};
}))).filter(state => state !== null);

Expand Down

0 comments on commit 3fe4c40

Please sign in to comment.