Skip to content

Commit

Permalink
fix(@angular/cli): ng e2e and ng lint prompt requires to hit Ente…
Browse files Browse the repository at this point in the history
…r twice to proceed on Windows

This fixes an issue where prompts in nested child processes on Windows require multiple keystrokes to proceed.

Closes #26724

(cherry picked from commit a391b5f)
  • Loading branch information
alan-agius4 committed Dec 21, 2023
1 parent d1923a6 commit 6dba26a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import {
WorkspaceNodeModulesArchitectHost,
} from '@angular-devkit/architect/node';
import { json } from '@angular-devkit/core';
import { spawnSync } from 'child_process';
import { existsSync } from 'fs';
import { resolve } from 'path';
import { existsSync } from 'node:fs';
import { resolve } from 'node:path';
import { isPackageNameSafeForAnalytics } from '../analytics/analytics';
import { EventCustomDimension, EventCustomMetric } from '../analytics/analytics-parameters';
import { assertIsError } from '../utilities/error';
Expand Down Expand Up @@ -248,14 +247,14 @@ export abstract class ArchitectBaseCommandModule<T extends object>
const packageToInstall = await this.getMissingTargetPackageToInstall(choices);
if (packageToInstall) {
// Example run: `ng add @angular-eslint/schematics`.
const binPath = resolve(__dirname, '../../bin/ng.js');
const { error } = spawnSync(process.execPath, [binPath, 'add', packageToInstall], {
stdio: 'inherit',
const AddCommandModule = (await import('../commands/add/cli')).default;
await new AddCommandModule(this.context).run({
interactive: true,
force: false,
dryRun: false,
defaults: false,
collection: packageToInstall,
});

if (error) {
throw error;
}
}
} else {
// Non TTY display error message.
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/src/commands/add/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const packageVersionExclusions: Record<string, string | Range> = {
'@angular/material': '7.x',
};

export default class AddCommadModule
export default class AddCommandModule
extends SchematicsCommandModule
implements CommandModuleImplementation<AddCommandArgs>
{
Expand Down

0 comments on commit 6dba26a

Please sign in to comment.