feat!: update bindings

This commit is contained in:
ObserverOfTime
2025-05-09 10:06:33 +03:00
committed by Michael Hoffmann
parent 41a2e70241
commit 8b209bbb95
23 changed files with 337 additions and 114 deletions

View File

@@ -16,4 +16,4 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
return exports;
}
NODE_API_MODULE(tree_sitter_PARSER_NAME_binding, Init)
NODE_API_MODULE(tree_sitter_hcl_binding, Init)

View File

@@ -1,9 +1,9 @@
/// <reference types="node" />
const assert = require("node:assert");
const { test } = require("node:test");
const Parser = require("tree-sitter");
test("can load grammar", () => {
const parser = new (require("tree-sitter"))();
const parser = new Parser();
assert.doesNotThrow(() => parser.setLanguage(require(".")));
});
});

View File

@@ -1,7 +1,11 @@
const root = require("path").join(__dirname, "..", "..");
module.exports = require("node-gyp-build")(root);
module.exports =
typeof process.versions.bun === "string"
// Support `bun build --compile` by being statically analyzable enough to find the .node file at build-time
? require(`../../prebuilds/${process.platform}-${process.arch}/tree-sitter-hcl.node`)
: require("node-gyp-build")(root);
try {
module.exports.nodeTypeInfo = require("../../src/node-types.json");
} catch (_) {}
} catch (_) {}