Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import chalk with import() syntax #46931

Merged
merged 1 commit into from
Nov 29, 2021
Merged
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
2 changes: 1 addition & 1 deletion scripts/browserIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check
const chalk = require("chalk");
const { join } = require("path");
const { readFileSync } = require("fs");
try {
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();
Expand Down