Skip to content
Open
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
9 changes: 6 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,11 @@ export default class AngularBundler implements Bundler {

createDemoLayout(demo, this.framework);

const ngBuildCommand = `npm run build-angular -- ${getProjectNameByDemo(demo)}`;
const ngBuildProcess = exec(ngBuildCommand);
const isWin = process.platform === 'win32';
const [npmCmd, npmArgs] = isWin
? ['cmd', ['/c', 'npm.cmd', 'run', 'build-angular', '--', getProjectNameByDemo(demo)]]
: ['npm', ['run', 'build-angular', '--', getProjectNameByDemo(demo)]];
const ngBuildProcess = spawn(npmCmd, npmArgs);
ngBuildProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
Expand Down
19 changes: 9 additions & 10 deletions apps/demos/utils/ts-to-js-converter/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,13 @@ const pipeSource = async (
}));
};

const execTsc = async (directory: string, args: string): Promise<string> => new Promise((resolve, reject) => {
cps.exec(`tsc ${args}`, (error, stdout, stderr) => {
if (error != null) {
// eslint-disable-next-line prefer-promise-reject-errors
return reject(`${error}\n${stderr}\n${stdout}`);
}
return resolve(stdout);
});
});
const execTsc = async (directory: string, args: string[]): Promise<string> => {
const [cmd, cmdArgs] = isWindows()
? ['cmd', ['/c', 'tsc.cmd', ...args]]
: ['tsc', args];
const { stdout } = await promisify(cps.execFile)(cmd, cmdArgs, { cwd: directory });
return stdout;
};

const compile = async (resolve: PathResolvers, log: Logger) => {
log.debug('compiling sources and unit tests');
Expand All @@ -109,7 +107,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 Expand Up @@ -140,6 +138,7 @@ const strip = async (resolve: PathResolvers, log: Logger) => {
});
};

// eslint-disable-next-line require-await
const replaceInFiles = async (filenamePatterns: string[], replacementCallback: (string) => string, resolvePath: (string) => string, log: Logger) => (
Promise.all(
filenamePatterns.map(async (pattern) => {
Expand Down
Loading