mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-04 07:02:12 +03:00
allow specifying the binary directory when making node_modules
This commit is contained in:
parent
0dca027c8e
commit
4e343b9b55
@ -4,13 +4,16 @@ load("@prelude//python:toolchain.bzl", "PythonToolchainInfo")
|
||||
def _node_modules_impl(ctx: "context") -> [DefaultInfo.type]:
|
||||
out = ctx.actions.declare_output("node_modules")
|
||||
|
||||
node_toolchain = ctx.attrs._node_toolchain[NodeToolchainInfo]
|
||||
|
||||
ctx.actions.run(
|
||||
[
|
||||
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
|
||||
ctx.attrs._node_toolchain[NodeToolchainInfo].build_node_modules[DefaultInfo].default_outputs,
|
||||
node_toolchain.build_node_modules[DefaultInfo].default_outputs,
|
||||
out.as_output(),
|
||||
"--package", ctx.attrs.package,
|
||||
"--package-lock", ctx.attrs.package_lock,
|
||||
"--bin-dir", node_toolchain.bin_dir[DefaultInfo].default_outputs,
|
||||
],
|
||||
category = "npm",
|
||||
)
|
||||
|
@ -1,10 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Make a fresh `node_modules` directory in an isolated directory.
|
||||
|
||||
This script assumes it has `npm` and its dependencies in the right `PATH` and
|
||||
`NODE_PATH`. Make sure that's set up properly using whatever installation method
|
||||
is necessary!
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
@ -31,9 +27,18 @@ if __name__ == "__main__":
|
||||
action="store_true",
|
||||
help="Don't run package post-install scripts",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bin-dir",
|
||||
help="Path to a node installation's binary directory. If present, will be treated as an extra entry in PATH for the duration of this command.",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.bin_dir:
|
||||
os.environ["PATH"] = "{}:{}".format(
|
||||
os.path.abspath(args.bin_dir), os.environ["PATH"]
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
# npm wants these to be real files for whatever reason, and will throw
|
||||
# errors if they're symlinks.
|
||||
|
@ -1,5 +1,5 @@
|
||||
NodeToolchainInfo = provider(fields=[
|
||||
"bin",
|
||||
"bin_dir",
|
||||
"node",
|
||||
"build_node_modules",
|
||||
])
|
||||
@ -12,7 +12,7 @@ def _node_toolchain_impl(ctx) -> [[DefaultInfo.type, NodeToolchainInfo.type]]:
|
||||
return [
|
||||
DefaultInfo(),
|
||||
NodeToolchainInfo(
|
||||
bin = ctx.attrs.bin[DefaultInfo].default_outputs,
|
||||
bin_dir = ctx.attrs.bin_dir,
|
||||
node = ctx.attrs.node[RunInfo],
|
||||
build_node_modules = ctx.attrs._build_node_modules,
|
||||
),
|
||||
@ -21,7 +21,7 @@ def _node_toolchain_impl(ctx) -> [[DefaultInfo.type, NodeToolchainInfo.type]]:
|
||||
node_toolchain = rule(
|
||||
impl = _node_toolchain_impl,
|
||||
attrs = {
|
||||
"bin": attrs.dep(
|
||||
"bin_dir": attrs.dep(
|
||||
default="prelude-nri//node:bin"
|
||||
),
|
||||
"node": attrs.dep(
|
||||
|
Loading…
Reference in New Issue
Block a user