opencc-sys 0.5.1+1.4.1

OpenCC bindings for Rust
Documentation
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_test")

package(default_visibility = ["//visibility:public"])

# Self-contained runtime sandbox mirroring an npm-install layout. node/opencc.js
# computes its package root from its own location and looks for the addon under
# <packageRoot>/build/Release, so the addon, its JS API, the config/dictionary
# assets, and the testcases are assembled into one tree here. The addon is
# located by a plain filesystem lookup (no node-gyp-build), so the test needs no
# npm packages at all.
copy_to_directory(
    name = "node_test_release",
    srcs = [
        "//data/config:config",
        "//data/dictionary:binary_dictionaries",
        "//node:js_srcs",
        "//node:opencc",
        "//scripts:prepare_node_prebuild_artifacts",
        "//test/testcases:testcases_js",
    ],
    out = "sandbox",
    replace_prefixes = {
        "node/opencc.node": "build/Release/opencc.node",
        "data/config": "build/Release",
        "data/dictionary": "build/Release",
    },
)

js_library(
    name = "test_entry",
    srcs = ["test_entry.js"],
)

# Run node/test.js with Node's built-in test runner against the Bazel-built
# addon. node:test ships with the Node runtime and opencc.js locates the addon
# without node-gyp-build, so the test has no npm dependencies (no pnpm-lock).
js_test(
    name = "node_test",
    size = "medium",
    data = [
        ":node_test_release",
        ":test_entry",
    ],
    entry_point = "test_entry.js",
    # Force the concise spec reporter; otherwise node:test defaults to the
    # verbose TAP reporter when stdout is not a TTY (e.g. under Bazel/CI).
    node_options = [
        "--test-reporter=spec",
        "--test-reporter-destination=stdout",
    ],
)