Skip to contentSkip to conversation

npm.bbclass: introduce NPM_PXORY

PATCH In review [email protected] 3 participants 3 messages Jan 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 npm.bbclass: introduce NPM_PXORY

From: Ming Liu <[email protected]>

This is needed to support building npm packages under environment with proxy setting.

---
 meta/classes/npm.bbclass | 10 ++++++++++
 1 file changed, 10 insertions(+)
meta/classes/npm.bbclass +10 -0
index 6dbae6b..0f37f30 100644
@@ -24,6 +24,9 @@ def npm_oe_arch_map(target_arch, d):
 NPM_ARCH ?= "${@npm_oe_arch_map(d.getVar('TARGET_ARCH'), d)}"
 NPM_INSTALL_DEV ?= "0"
 
+# Format: http://proxyhost:proxyport
+NPM_PROXY ?= ""
+
 npm_do_compile() {
 	# Copy in any additionally fetched modules
 	if [ -d ${WORKDIR}/node_modules ] ; then
@@ -32,6 +35,13 @@ npm_do_compile() {
 	# changing the home directory to the working directory, the .npmrc will
 	# be created in this directory
 	export HOME=${WORKDIR}
+	if [ -n "${NPM_PROXY}" ]; then
+		npm config set proxy ${NPM_PROXY}
+		npm config set https-proxy ${NPM_PROXY}
+	else
+		npm config set proxy null
+		npm config set https-proxy null
+	fi
 	if [  "${NPM_INSTALL_DEV}" = "1" ]; then
 		npm config set dev true
 	else
Signature · 1 line
2.7.4
#1 lore raw

meta/classes/npm.bbclass npm_do_compile() { · line 44

Quoted 7 lines · On Wed, 9 Jan 2019 at 18:24, <[email protected]> wrote:
meta/classes/npm.bbclass +7 -0
+       if [ -n "${NPM_PROXY}" ]; then
+               npm config set proxy ${NPM_PROXY}
+               npm config set https-proxy ${NPM_PROXY}
+       else
+               npm config set proxy null
+               npm config set https-proxy null
+       fi

Isn't it better to set those from http[s]_proxy environment variables which are standard?

Alex

#2 lore raw
Quoted 10 lines · Alexander Kanavin

meta/classes/npm.bbclass npm_do_compile() { · line 44

Quoted 7 lines
meta/classes/npm.bbclass +7 -0
+       if [ -n "${NPM_PROXY}" ]; then
+               npm config set proxy ${NPM_PROXY}
+               npm config set https-proxy ${NPM_PROXY}
+       else
+               npm config set proxy null
+               npm config set https-proxy null
+       fi

Isn't it better to set those from http[s]_proxy environment variables which are standard?

Please, unless there's a very good reason lets use the proxy variables that we already export to various other bits of the system.

If npm will respect http_proxy in the environment, then just use bb.utils.export_proxies.

Ross