diff --git a/tools/console/console.js b/tools/console/console.js index f04c2bfd70..4501ae3473 100644 --- a/tools/console/console.js +++ b/tools/console/console.js @@ -584,6 +584,10 @@ class Console extends ConsoleBase { }); } + isInteractive() { + return !this._headless; + } + setPretty(pretty) { // If we're being forced, do nothing. if (FORCE_PRETTY !== undefined) { diff --git a/tools/meteor-services/deploy.js b/tools/meteor-services/deploy.js index e0ff7afcaa..b4f6148730 100644 --- a/tools/meteor-services/deploy.js +++ b/tools/meteor-services/deploy.js @@ -179,6 +179,15 @@ function authedRpc(options) { delete rpcOptions.printDeployURL; if (infoResult.statusCode === 401 && rpcOptions.promptIfAuthFails) { + Console.error("Authentication failed or login token expired."); + + if (!Console.isInteractive()) { + return { + statusCode: 401, + errorMessage: "login failed." + }; + } + // Our authentication didn't validate, so prompt the user to log in // again, and resend the RPC if the login succeeds. var username = Console.readLine({