From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 4ad9af5c for ; Fri, 9 Nov 2018 12:25:49 +0000 (UTC) Received: (qmail 14302 invoked by alias); 9 Nov 2018 12:25:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43809 Received: (qmail 19627 invoked by uid 1010); 9 Nov 2018 12:25:36 -0000 X-Qmail-Scanner-Diagnostics: from mail-io1-f67.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.166.67):SA:0(-2.0/5.0):. Processed in 2.795713 secs); 09 Nov 2018 12:25:36 -0000 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=heDyB3XEK+deTgZn+hnNq+2/mSVaFjtzUYn4ZfxR6aM=; b=cUVoAKyWLj2aocQ3rvIOVuoqOliSJjIhzUI0VjMq0lasb+JDmimOqbVP2Sow1X9cAQ Y2k29l460e6cQkWFXliqqgQMF1KUShiqalDl3gTBOLX/DTQLKigFgnn/B7pjdhpapy8X BsCjq/nUgFDCbxCCG9OvCwRvRjPee2EOyVs3wqPnsqlTiemwyyN6LYc+ABfNk27pqHu1 /dM1MHxFst9imC5CHF4LdD2InjTMewXksJ0flcYyFp1/J+pByZgR9rcTtUBHU5VpE9PJ onQ2AJIOIE0lHn5SwUKcPTjJsEW1WQV4hprGkVC7Ly4jke9p+x/JViJSlJ+udpi8Nd45 LyGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=heDyB3XEK+deTgZn+hnNq+2/mSVaFjtzUYn4ZfxR6aM=; b=YEHwW5M48x4wLi8lDQAuT0LGQTH36uHMHnmPru4SQ+h0DdqqV+fTW8SvCLrWCqvJOm 8CRLb7rqVN+x23hS7RHpiagQtzEj3PpwQ5wkgklhFYGpJHpqTrQZjW1H+NrI/dtuWoX5 t2WVN6l9Ih6AQL6Zq5Hrp6kLVmrbLvGoQVjNHA3ABY2BbjPTvZJxzJmheASxu/R13rRm 76omSQqaPkX1psJuGB93rdbaI+jbCR2wpIj+IrslWOOKIVFkj3En5dC20VDoEeV173eu rocKo/csXkVtdlZEy5r2kGWvhfFXE95YnicxaMmHzpQp/STFcXCiJcVTF98uIvWMYaJA YF0A== X-Gm-Message-State: AGRZ1gI4wi85iki+yahawSnJ9N2HIKIQyawO6avEIc5laB3/x7pZNHzM qzswevbO8gpJIvdn+cCk4VP1cA1tRGeKsA== X-Google-Smtp-Source: AJdET5d0UeMkB0vN2FE+6xSzGnO5T7nTl7NKsyP8qS/+vj/RJrGyKh0jWAyxdxhAep+bkQWyQmDteQ== X-Received: by 2002:a5e:a805:: with SMTP id c5-v6mr7196102ioa.283.1541766330468; Fri, 09 Nov 2018 04:25:30 -0800 (PST) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [PATCH] Prevent npm completion from spamming update notifications Message-Id: <849C47D0-AC5A-46C1-AEF1-4740F79433D1@dana.is> Date: Fri, 9 Nov 2018 06:26:04 -0600 To: Zsh workers X-Mailer: Apple Mail (2.3445.100.39) Newer versions of npm (and maybe older ones? but i never encountered it = until now) check for updates whenever you run literally any sub-command, = including the one that handles completion, and if it thinks it has something important = to tell you about that it spams the screen with colourful ASCII-art boxes of = nonsense Fortunately the spam only makes its way to the screen once per session, = since every time after that _npm_completion redirects it to /dev/null. But the = npm call in _npm_completion is still wasting time on the update = check/notification even when it's not showing the result. So i offer two possible fixes: 1. A conservative one that suppresses the visible spam but leaves the = time- wasting checks 2. A more complete but possibly questionable one that monkey-patches = their _npm_completion to avoid the time-wasting checks Is the second one too weird to ship with the shell? (Both patches also change the type call to a $commands check) dana ### CONSERVATIVE PATCH ### diff --git a/Completion/Unix/Command/_npm b/Completion/Unix/Command/_npm index f5493a321..d069fc107 100644 --- a/Completion/Unix/Command/_npm +++ b/Completion/Unix/Command/_npm @@ -2,8 +2,8 @@ =20 # Node Package Manager completion, letting npm do all the completion = work =20 -if type npm > /dev/null; then - eval "$(npm completion)" +if (( $+commands[npm] )); then + eval "$(NPM_CONFIG_UPDATE_NOTIFIER=3Dfalse npm completion)" =20 _npm_completion "$@" fi ### FUNNY PATCH #### diff --git a/Completion/Unix/Command/_npm b/Completion/Unix/Command/_npm index f5493a321..c05f61c51 100644 --- a/Completion/Unix/Command/_npm +++ b/Completion/Unix/Command/_npm @@ -2,8 +2,13 @@ =20 # Node Package Manager completion, letting npm do all the completion = work =20 -if type npm > /dev/null; then - eval "$(npm completion)" +if (( $+commands[npm] )); then + eval "$(NPM_CONFIG_UPDATE_NOTIFIER=3Dfalse npm completion)" + # Monkey-patch their function to prevent update checks + functions[_npm_completion]=3D" + local -x NPM_CONFIG_UPDATE_NOTIFIER=3Dfalse; + ${functions[_npm_completion]} + " =20 _npm_completion "$@" fi