diff --git a/src/generator.ts b/src/generator.ts index df55b88..d6038be 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -99,6 +99,10 @@ export class Generator { installPlaywrightBrowsers: !this.options.noBrowsers, }; } + if (!process.stdin.isTTY) { + console.error('Non-interactive terminal detected. See --help for options, then run again with --quiet.'); + process.exit(1); + } const isDefinitelyTS = fs.existsSync(path.join(this.rootDir, 'tsconfig.json')); diff --git a/tests/integration.spec.ts b/tests/integration.spec.ts index 995a67d..02ac506 100644 --- a/tests/integration.spec.ts +++ b/tests/integration.spec.ts @@ -175,6 +175,10 @@ test('should install with "npm i" in GHA when using npm with package-lock disabl expect(workflowContent).not.toContain('run: npm ci'); }); +test('should require --quiet for non-interactive terminals', async ({ exec }) => { + await expect(exec('node', [path.join(__dirname, '..')])).rejects.toThrow('Non-interactive terminal detected'); +}); + test('should not prompt and skip existing files in --quiet mode', async ({ run, dir }) => { // First run: generate the project normally await run([], { installGitHubActions: false, testDir: 'tests', language: 'TypeScript', installPlaywrightDependencies: false, installPlaywrightBrowsers: false });