diff options
| -rw-r--r-- | bitbake/lib/bb/fetch2/npm.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index d9daec2092..b3a3a444ee 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py | |||
| @@ -79,16 +79,12 @@ class NpmEnvironment(object): | |||
| 79 | Using a npm config file seems more reliable than using cli arguments. | 79 | Using a npm config file seems more reliable than using cli arguments. |
| 80 | This class allows to create a controlled environment for npm commands. | 80 | This class allows to create a controlled environment for npm commands. |
| 81 | """ | 81 | """ |
| 82 | def __init__(self, d, configs=None, npmrc=None): | 82 | def __init__(self, d, configs=[], npmrc=None): |
| 83 | self.d = d | 83 | self.d = d |
| 84 | 84 | ||
| 85 | if configs: | 85 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) |
| 86 | self.user_config = tempfile.NamedTemporaryFile(mode="w", buffering=1) | 86 | for key, value in configs: |
| 87 | self.user_config_name = self.user_config.name | 87 | self.user_config.write("%s=%s\n" % (key, value)) |
| 88 | for key, value in configs: | ||
| 89 | self.user_config.write("%s=%s\n" % (key, value)) | ||
| 90 | else: | ||
| 91 | self.user_config_name = "/dev/null" | ||
| 92 | 88 | ||
| 93 | if npmrc: | 89 | if npmrc: |
| 94 | self.global_config_name = npmrc | 90 | self.global_config_name = npmrc |
| @@ -109,7 +105,7 @@ class NpmEnvironment(object): | |||
| 109 | workdir = tmpdir | 105 | workdir = tmpdir |
| 110 | 106 | ||
| 111 | def _run(cmd): | 107 | def _run(cmd): |
| 112 | cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config_name) + cmd | 108 | cmd = "NPM_CONFIG_USERCONFIG=%s " % (self.user_config.name) + cmd |
| 113 | cmd = "NPM_CONFIG_GLOBALCONFIG=%s " % (self.global_config_name) + cmd | 109 | cmd = "NPM_CONFIG_GLOBALCONFIG=%s " % (self.global_config_name) + cmd |
| 114 | return runfetchcmd(cmd, d, workdir=workdir) | 110 | return runfetchcmd(cmd, d, workdir=workdir) |
| 115 | 111 | ||
