Skip to content

Commit

Permalink
fix(plugin-eslint): ensure working directory exists before writing .e…
Browse files Browse the repository at this point in the history
…slintrc.json
  • Loading branch information
matejchalk committed Nov 30, 2023
1 parent ee539b3 commit 3f19d6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/plugin-eslint/src/lib/eslint-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { writeFile } from 'fs/promises';
import { mkdir, writeFile } from 'fs/promises';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
import { PluginConfig } from '@code-pushup/models';
Expand Down Expand Up @@ -39,6 +39,7 @@ export async function eslintPlugin(

// save inline config to file so runner can access it later
if (typeof eslintrc !== 'string') {
await mkdir(dirname(ESLINTRC_PATH), { recursive: true });
await writeFile(ESLINTRC_PATH, JSON.stringify(eslintrc));
}
const eslintrcPath = typeof eslintrc === 'string' ? eslintrc : ESLINTRC_PATH;
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-eslint/src/lib/runner.integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ESLint } from 'eslint';
import { rm, writeFile } from 'fs/promises';
import { mkdir, rm, writeFile } from 'fs/promises';
import os from 'os';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
Expand Down Expand Up @@ -48,6 +48,7 @@ describe('executeRunner', () => {
const config: ESLint.ConfigData = {
extends: '@code-pushup',
};
await mkdir(dirname(ESLINTRC_PATH), { recursive: true });
await writeFile(ESLINTRC_PATH, JSON.stringify(config));
});

Expand Down

0 comments on commit 3f19d6f

Please sign in to comment.