diff options
author | Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> | 2021-12-13 12:13:53 +0100 |
---|---|---|
committer | Anuj Mittal <anuj.mittal@intel.com> | 2021-12-28 11:32:05 +0800 |
commit | 56f6e7b5f86f1dc630c50a67e9027c1798a56a34 (patch) | |
tree | fbffbe44b85b77c2549ac1f0f67d8552f1dd5425 | |
parent | e5b8983bec98b33dab2706575b9e7763c102f720 (diff) | |
download | bitbake-56f6e7b5f86f1dc630c50a67e9027c1798a56a34.tar.gz |
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"
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 9f272ad7f76c1559e745e9af686d0a529f917659)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
-rw-r--r-- | lib/bb/fetch2/npm.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/bb/fetch2/npm.py b/lib/bb/fetch2/npm.py index d9daec209..b3a3a444e 100644 --- a/lib/bb/fetch2/npm.py +++ b/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) |