update
This commit is contained in:
parent
f090f0acc0
commit
43b005d487
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rs-diff-darwin",
|
||||
"version": "0.0.2",
|
||||
"name": "@mtfos/rs-diff-darwin",
|
||||
"version": "0.0.3",
|
||||
"description": "Template project for writing node package with napi-rs",
|
||||
"repository": "https://git.trj.tw/nodejs/rs-diff.git",
|
||||
"license": "MIT",
|
||||
@ -9,8 +9,7 @@
|
||||
"main": "index.darwin.node",
|
||||
"files": ["index.darwin.node"],
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.trj.tw",
|
||||
"access": "public"
|
||||
"@mtfos:registry": "https://gitlab.trj.tw/api/v4/projects/4/packages/npm/"
|
||||
},
|
||||
"os": ["darwin"],
|
||||
"cpu": ["x64"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rs-diff-linux",
|
||||
"version": "0.0.2",
|
||||
"name": "@mtfos/rs-diff-linux",
|
||||
"version": "0.0.3",
|
||||
"description": "Template project for writing node package with napi-rs",
|
||||
"repository": "https://git.trj.tw/nodejs/rs-diff.git",
|
||||
"license": "MIT",
|
||||
@ -9,8 +9,7 @@
|
||||
"main": "index.linux.node",
|
||||
"files": ["index.linux.node"],
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.trj.tw",
|
||||
"access": "public"
|
||||
"@mtfos:registry": "https://gitlab.trj.tw/api/v4/projects/4/packages/npm/"
|
||||
},
|
||||
"os": ["linux"],
|
||||
"cpu": ["x64"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "rs-diff-win32",
|
||||
"name": "@mtfos/rs-diff-win32",
|
||||
"version": "0.0.1",
|
||||
"description": "Template project for writing node package with napi-rs",
|
||||
"repository": "https://git.trj.tw/nodejs/rs-diff.git",
|
||||
@ -9,8 +9,7 @@
|
||||
"main": "index.win32.node",
|
||||
"files": ["index.win32.node"],
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.trj.tw",
|
||||
"access": "public"
|
||||
"@mtfos:registry": "https://gitlab.trj.tw/api/v4/projects/4/packages/npm/"
|
||||
},
|
||||
"os": ["win32"],
|
||||
"cpu": ["x64"]
|
||||
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rs-diff",
|
||||
"version": "0.0.2",
|
||||
"name": "@mtfos/rs-diff",
|
||||
"version": "0.0.3",
|
||||
"description": "Template project for writing node package with napi-rs",
|
||||
"author": "Jay <jay@trj.tw>",
|
||||
"main": "index.js",
|
||||
@ -14,8 +14,7 @@
|
||||
"node": ">= 8.9"
|
||||
},
|
||||
"publishConfig": {
|
||||
"registry": "https://npm.trj.tw",
|
||||
"access": "public"
|
||||
"@mtfos:registry": "https://gitlab.trj.tw/api/v4/projects/4/packages/npm/"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cargo build --release && napi build --platform --release ./index",
|
||||
@ -58,7 +57,7 @@
|
||||
}
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"rs-diff-darwin": "^0.0.2",
|
||||
"rs-diff-linux": "^0.0.2"
|
||||
"@mtfos/rs-diff-darwin": "^0.0.3",
|
||||
"@mtfos/rs-diff-linux": "^0.0.3"
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ const { version } = require('../package.json')
|
||||
|
||||
updatePackageJson(path.join(__dirname, '..', 'package.json'), {
|
||||
optionalDependencies: platforms.reduce((acc, cur) => {
|
||||
acc[`rs-diff-${cur}`] = `^${version}`
|
||||
acc[`@mtfos/rs-diff-${cur}`] = `^${version}`
|
||||
return acc
|
||||
}, {}),
|
||||
})
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -5,7 +5,7 @@ extern crate napi_derive;
|
||||
|
||||
use std::convert::TryInto;
|
||||
|
||||
use napi::{CallContext, Env, JsNumber, JsObject, JsString, Module, Result, Task};
|
||||
use napi::{CallContext, JsObject, JsString, Module, Result};
|
||||
|
||||
mod mdiff;
|
||||
|
||||
@ -35,12 +35,12 @@ fn diff_char(ctx: CallContext) -> Result<JsObject> {
|
||||
item.set_named_property(
|
||||
"count",
|
||||
ctx.env.create_int64(it.count.try_into().unwrap()).unwrap(),
|
||||
);
|
||||
item.set_named_property("value", ctx.env.create_string(&it.value).unwrap());
|
||||
item.set_named_property("added", ctx.env.get_boolean(it.added).unwrap());
|
||||
item.set_named_property("removed", ctx.env.get_boolean(it.removed).unwrap());
|
||||
)?;
|
||||
item.set_named_property("value", ctx.env.create_string(&it.value).unwrap())?;
|
||||
item.set_named_property("added", ctx.env.get_boolean(it.added).unwrap())?;
|
||||
item.set_named_property("removed", ctx.env.get_boolean(it.removed).unwrap())?;
|
||||
|
||||
obj.set_index(idx, item);
|
||||
obj.set_index(idx, item)?;
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user