From 496736579f1083e95d1434919fc2428d4cf70710 Mon Sep 17 00:00:00 2001 From: uhyo Date: Sat, 27 Nov 2021 16:20:00 +0900 Subject: [PATCH] Import chalk with import() syntax This makes code compatible with chalk v5.0.0. --- scripts/browserIntegrationTest.js | 2 +- scripts/build/utils.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/browserIntegrationTest.js b/scripts/browserIntegrationTest.js index 622af7cb43da0..1d11e3b3c8c47 100644 --- a/scripts/browserIntegrationTest.js +++ b/scripts/browserIntegrationTest.js @@ -1,5 +1,4 @@ // @ts-check -const chalk = require("chalk"); const { join } = require("path"); const { readFileSync } = require("fs"); try { @@ -18,6 +17,7 @@ const playwright = require("playwright"); const debugging = false; (async () => { + const chalk = (await import("chalk")).default; for (const browserType of ["chromium", "firefox"]) { const browser = await playwright[browserType].launch({ headless: !debugging }); const context = await browser.newContext(); diff --git a/scripts/build/utils.js b/scripts/build/utils.js index cfb7924d62399..3840cc79622c3 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -8,7 +8,6 @@ const mkdirp = require("mkdirp"); const del = require("del"); const File = require("vinyl"); const ts = require("../../lib/typescript"); -const chalk = require("chalk"); const which = require("which"); const { spawn } = require("child_process"); const { CancellationToken, CancelError, Deferred } = require("prex"); @@ -26,7 +25,8 @@ const { Readable, Duplex } = require("stream"); * @property {boolean} [hidePrompt] * @property {boolean} [waitForExit=true] */ -function exec(cmd, args, options = {}) { +async function exec(cmd, args, options = {}) { + const chalk = (await import("chalk")).default; return /**@type {Promise<{exitCode: number}>}*/(new Promise((resolve, reject) => { const { ignoreExitCode, cancelToken = CancellationToken.none, waitForExit = true } = options; cancelToken.throwIfCancellationRequested();