diff --git a/.env.example b/.env.example deleted file mode 100644 index 4add8e1..0000000 --- a/.env.example +++ /dev/null @@ -1 +0,0 @@ -API_KEY=abc123 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5013e8f..8c21059 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,14 @@ jobs: - name: Install dependencies run: pnpm install + - name: Build project + run: pnpm build + - name: Run tests run: pnpm test - name: Run lint run: pnpm lint + + - name: dotenv-diff scan + run: npx dotenv-diff diff --git a/test/e2e/cli.autoscan.e2e.test.ts b/test/e2e/cli.autoscan.e2e.test.ts index 38a354a..72f12d5 100644 --- a/test/e2e/cli.autoscan.e2e.test.ts +++ b/test/e2e/cli.autoscan.e2e.test.ts @@ -337,4 +337,54 @@ describe('no-flag autoscan', () => { ); expect(res.stdout).toContain('[high]'); }); + + it('will ingore files with excludeFiles option in config', () => { + const cwd = tmpDir(); + + fs.writeFileSync( + path.join(cwd, 'dotenv-diff.config.json'), + JSON.stringify( + { + excludeFiles: ['src/ignore/**'], + }, + null, + 2, + ), + ); + + fs.mkdirSync(path.join(cwd, 'src', 'ignore'), { recursive: true }); + fs.writeFileSync( + path.join(cwd, 'src', 'ignore', 'index.ts'), + `const secret = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";`, + ); + + const res = runCli(cwd, []); + expect(res.status).toBe(0); + expect(res.stdout).not.toContain('Potential secrets detected in codebase'); + }); + + it('excludes a single file using exclude option', () => { + const cwd = tmpDir(); + + fs.writeFileSync( + path.join(cwd, 'dotenv-diff.config.json'), + JSON.stringify( + { + exclude: ['src/secret.ts'], + }, + null, + 2, + ), + ); + + fs.mkdirSync(path.join(cwd, 'src'), { recursive: true }); + fs.writeFileSync( + path.join(cwd, 'src', 'secret.ts'), + `const secret = "sk_live_123456789";`, + ); + + const res = runCli(cwd, []); + expect(res.stdout).not.toContain('Potential secrets detected in codebase'); + expect(res.status).toBe(0); + }); });