-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
install_tools
option to yarn_modules rule (#60)
- Loading branch information
Showing
6 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@org_pubref_rules_node//node:rules.bzl", "node_binary") | ||
|
||
node_binary( | ||
name = "example", | ||
main = "example.js", | ||
deps = [ | ||
"@yarn_modules//:_all_", | ||
], | ||
) | ||
|
||
sh_test( | ||
name = "example_test", | ||
size = "small", | ||
srcs = ["example_test.sh"], | ||
data = [":example"], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Ref Example | ||
|
||
This example demonstrates the `install_tools` option. | ||
|
||
In this case, `yarn install` of the `ref` package triggers `node-gyp`, | ||
which in this case uses tools in `/bin` and `/usr/bin`. We normally | ||
take these for granted as being on the path but bazel runs the yarn | ||
install script in the bare environment, so we need to specify these | ||
explicitly to build up the appropriate `PATH`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
local_repository( | ||
name = "org_pubref_rules_node", | ||
path = "../..", | ||
) | ||
|
||
load("@org_pubref_rules_node//node:rules.bzl", "node_repositories", "yarn_modules") | ||
|
||
node_repositories() | ||
|
||
yarn_modules( | ||
name = "yarn_modules", | ||
deps = { | ||
"ref": "1.3.5", | ||
}, | ||
# yarn install of 'ref' triggers node-gyp. This will in turn | ||
# require 'sh' and 'dirname'. Explicitly make these tools | ||
# available during the yarn install step. | ||
install_tools = [ | ||
"sh", # /bin | ||
"dirname", # #/usr/bin | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const ref = require("ref"); | ||
|
||
const buf = new Buffer(4) | ||
|
||
buf.writeInt32LE(12345, 0) | ||
buf.type = ref.types.int | ||
|
||
console.log(buf.deref()) // ← 12345 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set -e | ||
|
||
if (./example &) | grep -q '12345'; then | ||
echo "PASS" | ||
else | ||
exit 1 | ||
fi |