Skip to content
Closed
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
5 changes: 2 additions & 3 deletions apps/demos/utils/create-bundles/Angular/bundler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { exec } from 'child_process';
import { spawn } from 'child_process';
import { BuildOptions } from 'esbuild';
import { existsSync, mkdirSync, removeSync } from 'fs-extra';
import { Demo, Framework } from '../helper/types';
Expand Down Expand Up @@ -42,8 +42,7 @@ export default class AngularBundler implements Bundler {

createDemoLayout(demo, this.framework);

const ngBuildCommand = `npm run build-angular -- ${getProjectNameByDemo(demo)}`;
const ngBuildProcess = exec(ngBuildCommand);
const ngBuildProcess = spawn('npm', ['run', 'build-angular', '--', getProjectNameByDemo(demo)], { shell: process.platform === 'win32' });
Comment thread
dxvladislavvolkov marked this conversation as resolved.
Comment thread
dxvladislavvolkov marked this conversation as resolved.
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
Expand Down
24 changes: 18 additions & 6 deletions apps/demos/utils/ts-to-js-converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,24 @@ const pipeSource = async (
}));
};

// eslint-disable-next-line require-await
const execTsc = async (directory: string, args: string): Promise<string> => new Promise((resolve, reject) => {
cps.exec(`tsc ${args}`, (error, stdout, stderr) => {
if (error != null) {
const execTsc = (directory: string, args: string[]): Promise<string> => new Promise((resolve, reject) => {
const proc = cps.spawn('tsc', args, { cwd: directory, shell: isWindows() });
Comment thread
dxvladislavvolkov marked this conversation as resolved.
let stdout = '';
let stderr = '';
proc.stdout.on('data', (data: Buffer) => { stdout += data.toString(); });
proc.stderr.on('data', (data: Buffer) => { stderr += data.toString(); });
proc.on('error', (err: Error) => {
// eslint-disable-next-line prefer-promise-reject-errors
reject(`tsc failed to spawn: ${err.message}`);
});
Comment thread
dxvladislavvolkov marked this conversation as resolved.
proc.on('close', (code: number | null, signal: string | null) => {
if (signal !== null) {
Comment thread
dxvladislavvolkov marked this conversation as resolved.
// eslint-disable-next-line prefer-promise-reject-errors
return reject(`tsc killed by signal ${signal}\n${stderr}\n${stdout}`);
}
Comment on lines +92 to +95
if (code !== 0) {
// eslint-disable-next-line prefer-promise-reject-errors
return reject(`${error}\n${stderr}\n${stdout}`);
return reject(`tsc exited with code ${code}\n${stderr}\n${stdout}`);
}
Comment on lines +96 to 99
return resolve(stdout);
});
Expand All @@ -110,7 +122,7 @@ const compile = async (resolve: PathResolvers, log: Logger) => {
),
);

await execTsc(resolve.source('./'), `--build ${tsconfigFile}`);
await execTsc(resolve.source('./'), ['--build', tsconfigFile]);
};

const copyAssets = async (resolve: PathResolvers, log: Logger) => {
Expand Down
Loading