diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/npm.bbclass | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass index dbfc2e728e..492935a85e 100644 --- a/meta/classes/npm.bbclass +++ b/meta/classes/npm.bbclass | |||
@@ -57,13 +57,36 @@ def npm_global_configs(d): | |||
57 | configs.append(("cache", d.getVar("NPM_CACHE"))) | 57 | configs.append(("cache", d.getVar("NPM_CACHE"))) |
58 | return configs | 58 | return configs |
59 | 59 | ||
60 | ## 'npm pack' runs 'prepare' and 'prepack' scripts. Support for | ||
61 | ## 'ignore-scripts' which prevents this behavior has been removed | ||
62 | ## from nodejs 16. Use simple 'tar' instead of. | ||
60 | def npm_pack(env, srcdir, workdir): | 63 | def npm_pack(env, srcdir, workdir): |
61 | """Run 'npm pack' on a specified directory""" | 64 | """Emulate 'npm pack' on a specified directory""" |
62 | import shlex | 65 | import subprocess |
63 | cmd = "npm pack %s" % shlex.quote(srcdir) | 66 | import os |
64 | args = [("ignore-scripts", "true")] | 67 | import json |
65 | tarball = env.run(cmd, args=args, workdir=workdir).strip("\n") | 68 | |
66 | return os.path.join(workdir, tarball) | 69 | src = os.path.join(srcdir, 'package.json') |
70 | with open(src) as f: | ||
71 | j = json.load(f) | ||
72 | |||
73 | # base does not really matter and is for documentation purposes | ||
74 | # only. But the 'version' part must exist because other parts of | ||
75 | # the bbclass rely on it. | ||
76 | base = j['name'].split('/')[-1] | ||
77 | tarball = os.path.join(workdir, "%s-%s.tgz" % (base, j['version'])); | ||
78 | |||
79 | # TODO: real 'npm pack' does not include directories while 'tar' | ||
80 | # does. But this does not seem to matter... | ||
81 | subprocess.run(['tar', 'czf', tarball, | ||
82 | '--exclude', './node-modules', | ||
83 | '--exclude-vcs', | ||
84 | '--transform', 's,^\./,package/,', | ||
85 | '--mtime', '1985-10-26T08:15:00.000Z', | ||
86 | '.'], | ||
87 | check = True, cwd = srcdir) | ||
88 | |||
89 | return tarball | ||
67 | 90 | ||
68 | python npm_do_configure() { | 91 | python npm_do_configure() { |
69 | """ | 92 | """ |