loqatevars
Version:
Locate JavaScript files with 'const' or 'process.env' usage in LLM-generated codebases
30 lines (24 loc) • 861 B
JavaScript
const path = require('path');
const fs = require('fs-extra');
const os = require('os');
const { execSync } = require('child_process');
// Verify that executing `node cli.js` scans the current working directory
describe('CLI execution from shell', () => {
let testDir;
let originalDir;
beforeEach(() => {
originalDir = process.cwd();
testDir = fs.mkdtempSync(path.join(os.tmpdir(), 'cli-run-'));
fs.writeFileSync(path.join(testDir, 'a.js'), 'const a = 1;');
});
afterEach(() => {
process.chdir(originalDir);
fs.removeSync(testDir);
});
test('node cli.js scans current working directory', () => {
process.chdir(testDir); // run CLI from temp directory
const cliPath = path.resolve(__dirname, '..', 'cli.js');
const output = execSync(`node ${cliPath}`).toString();
expect(output).toContain('a.js');
});
});