From 7f317ab9777abb6e2eb3af7e52f8324faa028dad Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Thu, 15 Oct 2026 16:13:11 +0200 Subject: [PATCH] [eas-cli] Print the eas-cli dependency notice only when stderr is a terminal The notice is advice for a person. A program that runs eas-cli reads stderr for the command's error and found this notice first. Co-Authored-By: Claude Opus 5.5 Co-Authored-By: Claude Fable 5.1 --- .changeset/dependency-notice-tty.md | 5 +++ ...ojectDirAndVerifyProjectSetupAsync-test.ts | 37 +++++++++++++++++++ ...indProjectDirAndVerifyProjectSetupAsync.ts | 3 +- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .changeset/dependency-notice-tty.md diff --git a/.changeset/dependency-notice-tty.md b/.changeset/dependency-notice-tty.md new file mode 100644 index 0000000000..24ddb8d1cd --- /dev/null +++ b/.changeset/dependency-notice-tty.md @@ -0,0 +1,5 @@ +--- +'eas-cli': patch +--- + +Print the notice about eas-cli in project dependencies only when stderr is a terminal, so programs that read stderr get the command's error. diff --git a/packages/eas-cli/src/commandUtils/context/contextUtils/__tests__/findProjectDirAndVerifyProjectSetupAsync-test.ts b/packages/eas-cli/src/commandUtils/context/contextUtils/__tests__/findProjectDirAndVerifyProjectSetupAsync-test.ts index 1dcb9492a0..f23c695b13 100644 --- a/packages/eas-cli/src/commandUtils/context/contextUtils/__tests__/findProjectDirAndVerifyProjectSetupAsync-test.ts +++ b/packages/eas-cli/src/commandUtils/context/contextUtils/__tests__/findProjectDirAndVerifyProjectSetupAsync-test.ts @@ -11,8 +11,16 @@ jest.mock('fs'); jest.mock('../../../../prompts'); +const originalStderrIsTTY = process.stderr.isTTY; + beforeEach(() => { jest.resetAllMocks(); + // The dependency notice prints once per process and only to a terminal, so keep it unspent. + process.stderr.isTTY = false; +}); + +afterAll(() => { + process.stderr.isTTY = originalStderrIsTTY; }); describe(findProjectRootAsync, () => { @@ -115,3 +123,32 @@ describe(findProjectDirAndVerifyProjectSetupAsync, () => { await expect(findProjectDirAndVerifyProjectSetupAsync({ cwd: '/app' })).resolves.not.toThrow(); }); }); + +describe('eas-cli dependency notice', () => { + beforeEach(() => { + vol.reset(); + vol.fromJSON( + { + './eas.json': JSON.stringify({}), + './package.json': JSON.stringify({ devDependencies: { 'eas-cli': '*' } }), + }, + '/app' + ); + }); + + afterEach(() => { + jest.restoreAllMocks(); + }); + + it('prints the notice only when stderr is a terminal', async () => { + const warn = jest.spyOn(console, 'warn').mockImplementation(() => {}); + + process.stderr.isTTY = false; + await findProjectDirAndVerifyProjectSetupAsync({ cwd: '/app' }); + expect(warn).not.toHaveBeenCalled(); + + process.stderr.isTTY = true; + await findProjectDirAndVerifyProjectSetupAsync({ cwd: '/app' }); + expect(warn).toHaveBeenCalledWith(expect.stringContaining('in your project dependencies')); + }); +}); diff --git a/packages/eas-cli/src/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.ts b/packages/eas-cli/src/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.ts index 77a939f37f..f03b202286 100644 --- a/packages/eas-cli/src/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.ts +++ b/packages/eas-cli/src/commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync.ts @@ -127,7 +127,8 @@ export async function findProjectDirAndVerifyProjectSetupAsync({ } = {}): Promise { const projectDir = await findProjectRootAsync({ cwd }); await applyCliConfigAsync(projectDir); - if (!ranEnsureEasCliIsNotInDependencies) { + // The notice is advice for a person. Programs that run eas-cli read stderr for its errors. + if (!ranEnsureEasCliIsNotInDependencies && process.stderr.isTTY) { ranEnsureEasCliIsNotInDependencies = true; await ensureEasCliIsNotInDependenciesAsync(projectDir); }