Skip to content

Commit f1edfa5

Browse files
devversionandrewseguin
authored andcommitted
build: do not prompt on postinstall in bazel yarn install (#20294)
Currently when Bazel runs the Yarn postinstall, we might prompt if the postinstall patches have been modified. This prompt runs forever as there is no input TTY. We fix this by not prompting if there is no TTY. i.e. always cleaning up the node modules in that case. (cherry picked from commit 5f87552)
1 parent 2aba7f6 commit f1edfa5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tools/postinstall/apply-patches.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,18 @@ async function readAndValidatePatchMarker() {
247247
console.error(chalk.red('cleaned up.'));
248248
}
249249

250-
const {cleanupModules} = await inquirer.prompt({
251-
name: 'cleanupModules',
252-
type: 'confirm',
253-
message: 'Clean up node modules automatically?',
254-
default: false
255-
});
250+
let cleanupModules = true;
251+
252+
// Do not prompt if there is no TTY. Inquirer does not skip in non-tty environments.
253+
// TODO: Remove once inquirer has been updated to v8.x where TTY is respected.
254+
if (process.stdin.isTTY) {
255+
cleanupModules = (await inquirer.prompt({
256+
name: 'result',
257+
type: 'confirm',
258+
message: 'Clean up node modules automatically?',
259+
default: false
260+
})).result;
261+
}
256262

257263
if (cleanupModules) {
258264
// This re-runs Yarn with `--check-files` mode. The postinstall will rerun afterwards,

0 commit comments

Comments
 (0)