Skip to content

Commit

Permalink
perf(npm): use actions.run instead of actions.run_shell (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored Aug 21, 2024
1 parent 4f5ef8c commit acd29eb
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions npm/private/npm_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,21 @@ def _npm_package_store_impl(ctx):
# tar to strip one directory level. Some packages have directory permissions missing
# executable which make the directories not listable ([email protected] for example).
bsdtar = ctx.toolchains["@aspect_bazel_lib//lib:tar_toolchain_type"]
args = ctx.actions.args()
args.add(bsdtar.tarinfo.binary)
args.add(src)
args.add(package_store_directory.path) # Need to use `.path` due to: Error in add: Cannot add directories to Args#add since they may expand to multiple values. Either use Args#add_all (if you want expansion) or args.add(directory.path).
ctx.actions.run_shell(
tools = [bsdtar.tarinfo.binary],
ctx.actions.run(
executable = bsdtar.tarinfo.binary,
inputs = depset(direct = [src], transitive = [bsdtar.default.files]),
outputs = [package_store_directory],
command = "$1 --extract --no-same-owner --no-same-permissions --strip-components 1 --file $2 --directory $3",
arguments = [args],
arguments = [
"--extract",
"--no-same-owner",
"--no-same-permissions",
"--strip-components",
"1",
"--file",
src.path,
"--directory",
package_store_directory.path,
],
mnemonic = "NpmPackageExtract",
progress_message = "Extracting npm package {}@{}".format(package, version),
)
Expand Down

0 comments on commit acd29eb

Please sign in to comment.