MCPcopy Create free account
hub / github.com/SoCreate/angular-playground / buildAngularCli

Function buildAngularCli

projects/cli/src/build-angular-cli.ts:3–27  ·  view source on GitHub ↗
(appName: string, enableServiceWorker: boolean, baseHref: string, maxBuffer: number | string)

Source from the content-addressed store, hash-verified

1import { exec } from 'child_process';
2
3export async function buildAngularCli(appName: string, enableServiceWorker: boolean, baseHref: string, maxBuffer: number | string) {
4 let isInstalled = await serviceWorkerIsInstalled();
5 if (enableServiceWorker && !isInstalled) {
6 throw new Error('\n\nError: --build-with-service-worker requires @angular/service-worker to be installed locally: \n' +
7 'try running "npm install @angular/service-worker" then run "angular-playground --build" \n' +
8 'see docs: https://github.com/angular/angular-cli/wiki/build#service-worker\n\n');
9 }
10
11 console.log('Building for production with sandboxes...');
12
13 const options = Number.isInteger(+maxBuffer) ? { maxBuffer: +maxBuffer } : {};
14 // Cannot build w/ AOT due to runtime compiler dependency
15 const flags = [
16 `-c=production`,
17 '--aot=false',
18 `--base-href=${baseHref}`,
19 `--service-worker=${enableServiceWorker}`,
20 ];
21 exec(`ng build ${appName} ${flags.join(' ')}`,
22 options,
23 (err, stdout, stderr) => {
24 if (err) throw err;
25 console.log(stdout);
26 });
27}
28
29async function serviceWorkerIsInstalled(): Promise<boolean> {
30 return new Promise<boolean>((resolve, reject) => {

Callers 1

runFunction · 0.90

Calls 1

serviceWorkerIsInstalledFunction · 0.85

Tested by

no test coverage detected