feat:fix doric-cli cannot output compile errors

This commit is contained in:
pengfeizhou 2021-02-25 17:47:50 +08:00 committed by osborn
parent be1514e830
commit 1887e1e322
4 changed files with 39 additions and 4 deletions

View File

@ -4,8 +4,26 @@ import fs from "fs";
import { glob } from "./util";
import path from "path";
export async function build() {
await Shell.exec("node", ["node_modules/.bin/tsc", "-p", "."]);
await Shell.exec("node", ["node_modules/.bin/rollup", "-c"]);
let ret = await Shell.exec("node", ["node_modules/.bin/tsc", "-p", "."], {
env: process.env,
consoleHandler: (info) => {
console.log(info);
}
});
if (ret !== 0) {
console.log("Compile error".red);
return;
}
ret = await Shell.exec("node", ["node_modules/.bin/rollup", "-c",], {
env: process.env,
consoleHandler: (info) => {
console.log(info);
}
});
if (ret !== 0) {
console.log("Compile error".red);
return;
}
const bundleFiles = await glob("bundle/**/*.js");
for (let bundleFile of bundleFiles) {
await doMerge(bundleFile);

View File

@ -31,8 +31,21 @@ function getIPAdress() {
export default async function dev() {
const server = await createServer()
const tscProcess = exec("node node_modules/.bin/tsc -w -p .");
const rollupProcess = exec("node node_modules/.bin/rollup -c -w");
const tscProcess = exec("node node_modules/.bin/tsc -w -p .", {
env: process.env,
});
const rollupProcess = exec("node node_modules/.bin/rollup -c -w", {
env: process.env,
});
[tscProcess, rollupProcess].forEach(e => {
e.stdout?.on("data", (data) => {
console.log(data.toString());
});
e.stderr?.on("data", (data) => {
console.log(data.toString());
});
})
console.warn("Waiting ...");
const ips = getIPAdress();
ips.forEach((e) => {

View File

@ -5,6 +5,9 @@ import { build, clean } from "./actions";
import create from "./create"
import dev from "./dev"
import { run } from "./run";
(process.env.FORCE_COLOR as any) = true
commander
.command('create <name>')
.action(async function (name, cmd) {

View File

@ -34,6 +34,7 @@ async function runAndroid() {
console.log("====================");
await Shell.exec("sh", ["gradlew", "assembleDebug"], {
cwd: androidDir,
env: process.env,
consoleHandler: (info) => console.log(info)
});
const apkFiles = await glob("**/outputs/apk/debug/*.apk", {