From 9b5cf1010a3a489181e354a2ac4b04b726465cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 12 Nov 2026 14:52:28 +0000 Subject: [PATCH] chore: fix build for checkouts under a dot-directory --- babel.config.js | 4 +++- scripts/build.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/babel.config.js b/babel.config.js index 28ea2337d..7479fd368 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,7 +3,9 @@ module.exports = { overrides: [ { presets: ['@babel/preset-typescript'], - test: '**/*.ts', + // A RegExp, because a `**/*.ts` glob doesn't match files under a + // dot-directory (e.g. a checkout in ~/.worktrees/cli). + test: /\.ts$/, }, ], presets: [ diff --git a/scripts/build.js b/scripts/build.js index 2f8e587f6..e3ccb4e91 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -65,10 +65,16 @@ function buildNodePackage(p) { process.stdout.write(`${OK}\n`); } +// Match globs against the path inside the package, so a checkout under a +// dot-directory (e.g. ~/.worktrees/cli) doesn't stop `**` from matching. +function matchesPattern(file, pattern) { + return micromatch.isMatch(path.relative(PACKAGES_DIR, file), pattern); +} + function buildFile(file, silent) { const destPath = getBuildPath(file, BUILD_DIR); - if (micromatch.isMatch(file, IGNORE_PATTERN)) { + if (matchesPattern(file, IGNORE_PATTERN)) { silent || process.stdout.write( `${ @@ -83,8 +89,8 @@ function buildFile(file, silent) { const fileName = path.basename(file); if ( - !micromatch.isMatch(file, JS_FILES_PATTERN) && - !micromatch.isMatch(file, TS_FILE_PATTERN) + !matchesPattern(file, JS_FILES_PATTERN) && + !matchesPattern(file, TS_FILE_PATTERN) ) { if (FILES_WITH_755_PERMISSION.includes(fileName)) { fs.createReadStream(file).pipe(