mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-04 07:02:12 +03:00
make it possible to run installation scripts in our repo
This commit is contained in:
parent
ecfce394df
commit
595dc838a1
3
BUCK
3
BUCK
@ -18,6 +18,9 @@ node_modules(
|
||||
name = "node_modules",
|
||||
package = "package.json",
|
||||
package_lock = "package-lock.json",
|
||||
extra_files = {
|
||||
"lib": "//lib:src"
|
||||
},
|
||||
)
|
||||
|
||||
npm_bin(
|
||||
|
6
lib/BUCK
6
lib/BUCK
@ -5,3 +5,9 @@ genrule(
|
||||
cmd = "$(exe //:browserify) index.js --outfile $OUT",
|
||||
visibility = ["//component-catalog:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "src",
|
||||
srcs = glob(["**/*.js"]),
|
||||
visibility = ["//:node_modules"],
|
||||
)
|
||||
|
@ -6,21 +6,23 @@ def _node_modules_impl(ctx: "context") -> [DefaultInfo.type]:
|
||||
|
||||
node_toolchain = ctx.attrs._node_toolchain[NodeToolchainInfo]
|
||||
|
||||
ctx.actions.run(
|
||||
[
|
||||
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
|
||||
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",
|
||||
cmd = cmd_args(
|
||||
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
|
||||
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,
|
||||
)
|
||||
|
||||
for (name, value) in (ctx.attrs.extra_files or {}).items():
|
||||
cmd.add(cmd_args(value, format = "--extra-file=" + name + "={}"))
|
||||
|
||||
ctx.actions.run(cmd, category = "npm")
|
||||
|
||||
return [DefaultInfo(default_output = out)]
|
||||
|
||||
node_modules = rule(
|
||||
@ -28,6 +30,13 @@ node_modules = rule(
|
||||
attrs = {
|
||||
"package": attrs.source(),
|
||||
"package_lock": attrs.source(),
|
||||
"extra_files": attrs.option(
|
||||
attrs.dict(
|
||||
attrs.string(),
|
||||
attrs.source(allow_directory = True),
|
||||
),
|
||||
default = None,
|
||||
),
|
||||
"_node_toolchain": attrs.toolchain_dep(
|
||||
default = "toolchains//:node",
|
||||
providers = [NodeToolchainInfo],
|
||||
|
Loading…
Reference in New Issue
Block a user