]> code.ossystems Code Review - openembedded-core.git/commitdiff
npm: Use configs for npm environment and args for npm run command
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Fri, 8 Oct 2021 07:48:34 +0000 (09:48 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Oct 2021 10:48:35 +0000 (11:48 +0100)
Use parameter configs of class NpmEnvironment and parameter args of
function run to support a common npmrc for all run calls of a single
NpmEnvironment.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/npm.bbclass

index 05bb9f578d74a10d9348b890058facdcfa01b253..547c531883bf197606b2bc10332e9051fe87762f 100644 (file)
@@ -61,8 +61,8 @@ def npm_pack(env, srcdir, workdir):
     """Run 'npm pack' on a specified directory"""
     import shlex
     cmd = "npm pack %s" % shlex.quote(srcdir)
-    configs = [("ignore-scripts", "true")]
-    tarball = env.run(cmd, configs=configs, workdir=workdir).strip("\n")
+    args = [("ignore-scripts", "true")]
+    tarball = env.run(cmd, args=args, workdir=workdir).strip("\n")
     return os.path.join(workdir, tarball)
 
 python npm_do_configure() {
@@ -228,15 +228,11 @@ python npm_do_compile() {
 
     bb.utils.remove(d.getVar("NPM_BUILD"), recurse=True)
 
-    env = NpmEnvironment(d, configs=npm_global_configs(d))
-
-    dev = bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False)
-
     with tempfile.TemporaryDirectory() as tmpdir:
         args = []
-        configs = []
+        configs = npm_global_configs(d)
 
-        if dev:
+        if bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False):
             configs.append(("also", "development"))
         else:
             configs.append(("only", "production"))
@@ -254,6 +250,8 @@ python npm_do_compile() {
         configs.append(("nodedir", d.getVar("NPM_NODEDIR")))
         configs.append(("python", d.getVar("PYTHON")))
 
+        env = NpmEnvironment(d, configs)
+
         # Add node-pre-gyp configuration
         args.append(("target_arch", d.getVar("NPM_ARCH")))
         args.append(("build-from-source", "true"))