Skip to content

Commit

Permalink
build: add prebuildify
Browse files Browse the repository at this point in the history
  • Loading branch information
ObserverOfTime committed Mar 15, 2024
1 parent adfa6b4 commit 29485b6
Show file tree
Hide file tree
Showing 4 changed files with 369 additions and 25 deletions.
2 changes: 0 additions & 2 deletions bindings/node/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ const napi_type_tag LANGUAGE_TYPE_TAG = {
Napi::Object Init(Napi::Env env, Napi::Object exports) {
auto xml = Napi::Object::New(env);
xml["name"] = Napi::String::New(env, "PARSER_NAME");
xml["language"] = Napi::External<TSLanguage>::New(env, tree_sitter_xml());
auto xml_language = Napi::External<TSLanguage>::New(env, tree_sitter_xml());
xml_language.TypeTag(&LANGUAGE_TYPE_TAG);
xml["language"] = xml_language;

auto dtd = Napi::Object::New(env);
dtd["name"] = Napi::String::New(env, "PARSER_NAME");
dtd["language"] = Napi::External<TSLanguage>::New(env, tree_sitter_dtd());
auto dtd_language = Napi::External<TSLanguage>::New(env, tree_sitter_dtd());
dtd_language.TypeTag(&LANGUAGE_TYPE_TAG);
dtd["language"] = dtd_language;
Expand Down
22 changes: 5 additions & 17 deletions bindings/node/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
try {
module.exports = require('../../build/Release/tree_sitter_xml_binding');
} catch (error1) {
if (error1.code !== 'MODULE_NOT_FOUND') {
throw error1;
}
try {
module.exports = require('../../build/Debug/tree_sitter_xml_binding');
} catch (error2) {
if (error2.code !== 'MODULE_NOT_FOUND') {
throw error2;
}
throw error1
}
}
const root = require("path").join(__dirname, "..", "..");

module.exports = require("node-gyp-build")(root);

try {
module.exports.xml.nodeTypeInfo = require('../../xml/src/node-types.json');
module.exports.dtd.nodeTypeInfo = require('../../dtd/src/node-types.json');
module.exports.xml.nodeTypeInfo = require("../../xml/src/node-types.json");
module.exports.dtd.nodeTypeInfo = require("../../dtd/src/node-types.json");
} catch (_) { }
Loading

0 comments on commit 29485b6

Please sign in to comment.