Skip to content

Commit ed9bfe3

Browse files
authored
Merge pull request #97 from Chrilleweb/cmn/dev
Added dotenv-diff to ci + more tests
2 parents f264924 + deeef80 commit ed9bfe3

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ jobs:
2828
- name: Install dependencies
2929
run: pnpm install
3030

31+
- name: Build project
32+
run: pnpm build
33+
3134
- name: Run tests
3235
run: pnpm test
3336

3437
- name: Run lint
3538
run: pnpm lint
39+
40+
- name: dotenv-diff scan
41+
run: npx dotenv-diff

test/e2e/cli.autoscan.e2e.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,54 @@ describe('no-flag autoscan', () => {
337337
);
338338
expect(res.stdout).toContain('[high]');
339339
});
340+
341+
it('will ingore files with excludeFiles option in config', () => {
342+
const cwd = tmpDir();
343+
344+
fs.writeFileSync(
345+
path.join(cwd, 'dotenv-diff.config.json'),
346+
JSON.stringify(
347+
{
348+
excludeFiles: ['src/ignore/**'],
349+
},
350+
null,
351+
2,
352+
),
353+
);
354+
355+
fs.mkdirSync(path.join(cwd, 'src', 'ignore'), { recursive: true });
356+
fs.writeFileSync(
357+
path.join(cwd, 'src', 'ignore', 'index.ts'),
358+
`const secret = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";`,
359+
);
360+
361+
const res = runCli(cwd, []);
362+
expect(res.status).toBe(0);
363+
expect(res.stdout).not.toContain('Potential secrets detected in codebase');
364+
});
365+
366+
it('excludes a single file using exclude option', () => {
367+
const cwd = tmpDir();
368+
369+
fs.writeFileSync(
370+
path.join(cwd, 'dotenv-diff.config.json'),
371+
JSON.stringify(
372+
{
373+
exclude: ['src/secret.ts'],
374+
},
375+
null,
376+
2,
377+
),
378+
);
379+
380+
fs.mkdirSync(path.join(cwd, 'src'), { recursive: true });
381+
fs.writeFileSync(
382+
path.join(cwd, 'src', 'secret.ts'),
383+
`const secret = "sk_live_123456789";`,
384+
);
385+
386+
const res = runCli(cwd, []);
387+
expect(res.stdout).not.toContain('Potential secrets detected in codebase');
388+
expect(res.status).toBe(0);
389+
});
340390
});

0 commit comments

Comments
 (0)