summaryrefslogtreecommitdiff
path: root/poky/bitbake
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2021-12-13 14:13:53 +0300
committerAndrew Geissler <geissonator@yahoo.com>2022-01-24 20:02:44 +0300
commit3d983ec73c4ad6449330ce781eb125564979d42e (patch)
tree13c77eb64719066ed08e59e6417118e2c7712539 /poky/bitbake
parenteff27476badc5d48b544a07f9f4748a96506c8d7 (diff)
downloadopenbmc-3d983ec73c4ad6449330ce781eb125564979d42e.tar.xz
bitbake: fetch: npm: Use temporary file for empty user config
Always use a temporary file for the user config 'NPM_CONFIG_USERCONFIG' because npm otherwise failed if configs and npmrc aren't set: double-loading config "/dev/null" as "global", previously loaded as "user" (Bitbake rev: 9f272ad7f76c1559e745e9af686d0a529f917659) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Andrew Geissler <geissonator@yahoo.com> Change-Id: I24c35d1393495e1874573cd731f84c41382ee95e
Diffstat (limited to 'poky/bitbake')
-rw-r--r--poky/bitbake/lib/bb/fetch2/npm.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/poky/bitbake/lib/bb/fetch2/npm.py b/poky/bitbake/lib/bb/fetch2/npm.py
index e497c38dc7..3c41cb295c 100644
--- a/poky/bitbake/lib/bb/fetch2/npm.py
+++ b/poky/bitbake/lib/bb/fetch2/npm.py
@@ -79,16 +79,12 @@ class NpmEnvironment(object):
Using a npm config file seems more reliable than using cli arguments.
This class allows to create a controlled environment for npm commands.
"""
- def __init__(self, d, configs=None, npmrc=None):
+ def __init__(self, d, configs=[], npmrc=None):
self.d = d
- if configs:
- self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1)
- self.user_config_name = self.user_config.name
- for key, value in configs:
- self.user_config.write("%s=%s\n" % (key, value))
- else:
- self.user_config_name = "/dev/null"
+ self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1)
+ for key, value in configs:
+ self.user_config.write("%s=%s\n" % (key, value))
if npmrc:
self.global_config_name = npmrc
@@ -109,7 +105,7 @@ class NpmEnvironment(object):
workdir = tmpdir
def _run(cmd):
- cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config_name) + cmd
+ cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config.name) + cmd
cmd = "NPM_CONFIG_GLOBALCONFIG=%s " % (self.global_config_name) + cmd
return runfetchcmd(cmd, d, workdir=workdir)