Update build scripts to async import execa

This commit is contained in:
Tom Coleman 2022-11-09 14:27:19 +11:00
parent 74a70c90fa
commit f1017f15d0
2 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,6 @@
/* eslint-disable no-console */
const fs = require('fs-extra');
const path = require('path');
const execa = require('execa');
const { join } = require('path');
function getCommand(watch, dir) {
@ -55,11 +54,13 @@ function handleExit(code, stderr, errorCallback) {
}
async function run({ watch, dir, silent, errorCallback }) {
const execa = await import('execa');
return new Promise((resolve, reject) => {
const command = getCommand(watch, dir);
if (command !== '') {
const child = execa.command(command, {
const child = execa.execaCommand(command, {
cwd: join(__dirname, '..'),
buffer: false,
env: { BABEL_MODE: path.basename(dir) },

View File

@ -1,7 +1,6 @@
/* eslint-disable no-console */
const fs = require('fs-extra');
const path = require('path');
const execa = require('execa');
function getCommand(watch) {
const args = [
@ -41,11 +40,13 @@ function handleExit(code, stderr, errorCallback) {
}
async function run({ optimized, watch, silent, errorCallback }) {
const execa = await import('execa');
return new Promise((resolve, reject) => {
const [command, tscOnly] = getCommand(watch);
if (tscOnly || optimized) {
const child = execa.command(command, {
const child = execa.execaCommand(command, {
buffer: false,
});
let stderr = '';