Improve Node.js compatibility
This commit is contained in:
parent
afdc4998e7
commit
c1e7c64cdd
|
@ -246,13 +246,16 @@ rollback:
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void define_method(napi_env env, napi_value exports, char const* name, napi_callback cb) {
|
||||||
|
napi_value js_fn;
|
||||||
|
assert_ok(napi_create_function(env, name, NAPI_AUTO_LENGTH, cb, NULL, &js_fn));
|
||||||
|
assert_ok(napi_set_named_property(env, exports, name, js_fn));
|
||||||
|
}
|
||||||
|
|
||||||
napi_value node_module_init(napi_env env, napi_value exports) {
|
napi_value node_module_init(napi_env env, napi_value exports) {
|
||||||
napi_property_descriptor props[] = {
|
define_method(env, exports, "createConfiguration", node_method_create_configuration);
|
||||||
{"createConfiguration", NULL, node_method_create_configuration, NULL, NULL, NULL, napi_default, NULL},
|
define_method(env, exports, "minify", node_method_minify);
|
||||||
{"minify", NULL, node_method_minify, NULL, NULL, NULL, napi_default, NULL},
|
define_method(env, exports, "minifyInPlace", node_method_minify_in_place);
|
||||||
{"minifyInPlace", NULL, node_method_minify_in_place, NULL, NULL, NULL, napi_default, NULL},
|
|
||||||
};
|
|
||||||
assert_ok(napi_define_properties(env, exports, 3, props));
|
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/wilsonzlin/minify-html/issues"
|
"url": "https://github.com/wilsonzlin/minify-html/issues"
|
||||||
},
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.6.0"
|
||||||
|
},
|
||||||
"homepage": "https://github.com/wilsonzlin/minify-html#readme",
|
"homepage": "https://github.com/wilsonzlin/minify-html#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-gyp": "^7.0.0"
|
"node-gyp": "^7.0.0"
|
||||||
|
|
Loading…
Reference in New Issue