Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/schematics/angular/ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,12 @@ async function isServerRoutingEnabled(
return serverRoutingDefault;
}

// `inquirer` requires `async_hooks` which isn't supported by webcontainers, therefore we can't prompt in that context.
// See: https://github.com/SBoudrias/Inquirer.js/issues/1426
if (process.versions.webcontainer) {
return serverRoutingDefault;
}

// Prompt the user if in an interactive terminal and no option was provided.
return await prompt(
'Would you like to use the Server Routing and App Engine APIs (Developer Preview) for this server application?',
Expand Down
17 changes: 17 additions & 0 deletions packages/schematics/angular/ssr/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('SSR Schematic', () => {

afterEach(() => {
process.env['NG_FORCE_TTY'] = originalTty;
delete process.versions.webcontainer;
});

it('should add script section in package.json', async () => {
Expand Down Expand Up @@ -230,6 +231,22 @@ describe('SSR Schematic', () => {

expect(tree.exists('/projects/test-app/src/app/app.routes.server.ts')).toBeFalse();
});

it('does not prompt when running in a web container', async () => {
const prompter = jasmine.createSpy<Prompt>('prompt').and.resolveTo(false);
setPrompterForTestOnly(prompter);

process.versions.webcontainer = 'abc123'; // Simulate webcontainer.
const tree = await schematicRunner.runSchematic(
'ssr',
{ ...defaultOptions, serverRouting: undefined },
appTree,
);

expect(prompter).not.toHaveBeenCalled();

expect(tree.exists('/projects/test-app/src/app/app.routes.server.ts')).toBeFalse();
});
});

describe('Legacy browser builder', () => {
Expand Down