From f4a2c130a9db14fcf94e27fc9bb05437f00695f0 Mon Sep 17 00:00:00 2001 From: Riley Martine Date: Mon, 6 May 2024 20:11:59 -0600 Subject: [PATCH] spawn fewer locomotives in projects with many roots --- packages/jest-changed-files/src/sl.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/jest-changed-files/src/sl.ts b/packages/jest-changed-files/src/sl.ts index 3530493d0200..c0553c6a2e1b 100644 --- a/packages/jest-changed-files/src/sl.ts +++ b/packages/jest-changed-files/src/sl.ts @@ -17,6 +17,9 @@ import type {SCMAdapter} from './types'; */ const env = {...process.env, HGPLAIN: '1'}; +// Whether `sl` is a steam locomotive or not +let isSteamLocomotive = false; + const adapter: SCMAdapter = { findChangedFiles: async (cwd, options) => { const includePaths = options.includePaths ?? []; @@ -55,6 +58,10 @@ const adapter: SCMAdapter = { }, getRoot: async cwd => { + if (isSteamLocomotive) { + return null; + } + try { const subprocess = execa('sl', ['root'], {cwd, env}); @@ -65,6 +72,7 @@ const adapter: SCMAdapter = { data = Buffer.isBuffer(data) ? data.toString() : data; if (data.codePointAt(0) === 27) { subprocess.cancel(); + isSteamLocomotive = true; } }); }