nodejs-nomer 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/package.json +3 -3
- package/src/index.js +2 -6
- package/src/result.js +2 -4
- package/src/utils.js +7 -15
- package/webpack.config.js +0 -17
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./dist')
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodejs-nomer",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "NodeJS wrapper for nomer",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nomer": "./bin/nomer"
|
|
7
7
|
},
|
|
8
|
-
"main": "
|
|
8
|
+
"main": "index.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "npm run test",
|
|
11
|
-
"build": "
|
|
11
|
+
"build": "babel src -d dist",
|
|
12
12
|
"preinstall": "./install_nomer.sh"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
package/src/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import Result from './result'
|
|
|
3
3
|
import { getProperties } from "properties-file";
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class Nomer {
|
|
6
|
+
export class Nomer {
|
|
7
7
|
|
|
8
8
|
propertiesPath = null;
|
|
9
9
|
echoOpt = "";
|
|
@@ -104,8 +104,4 @@ class Nomer {
|
|
|
104
104
|
const schemaAppend = JSON.parse(properties["nomer.append.schema.output"]).map((i) => i.type)
|
|
105
105
|
return Result.tsv(result, [...schemaInput, "matchType", ...schemaAppend])
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
module.exports = Nomer;
|
|
107
|
+
}
|
package/src/result.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class Result {
|
|
1
|
+
export class Result {
|
|
2
2
|
|
|
3
3
|
static json(result) {
|
|
4
4
|
const arr = [];
|
|
@@ -14,6 +14,4 @@ class Result {
|
|
|
14
14
|
|
|
15
15
|
return columns ? arr.map((v) => Object.assign(...columns.map((k, i) => ({ [k]: v[i] })))) : arr
|
|
16
16
|
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
module.exports = Result
|
|
17
|
+
}
|
package/src/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const { execSync,
|
|
1
|
+
const { execSync, spawn } = require('child_process')
|
|
2
2
|
|
|
3
|
-
const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties = null) => {
|
|
3
|
+
export const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties = null) => {
|
|
4
4
|
if (filepath === "") {
|
|
5
5
|
throw new Exception("Filepath cannot be empty string");
|
|
6
6
|
}
|
|
@@ -12,7 +12,7 @@ const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties =
|
|
|
12
12
|
return nomerCmd;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const getNomerMatchCmd = (query = "", cmd = "append", matcher = "globi-taxon-cache", properties = null, outputFormat = null, echoOpt = "-e") => {
|
|
15
|
+
export const getNomerMatchCmd = (query = "", cmd = "append", matcher = "globi-taxon-cache", properties = null, outputFormat = null, echoOpt = "-e") => {
|
|
16
16
|
let nomerCmd = `echo ${echoOpt} '${query}' | nomer ${cmd} ${matcher}`;
|
|
17
17
|
if (properties) {
|
|
18
18
|
nomerCmd = `${nomerCmd} -p ${properties}`;
|
|
@@ -24,7 +24,7 @@ const getNomerMatchCmd = (query = "", cmd = "append", matcher = "globi-taxon-cac
|
|
|
24
24
|
return nomerCmd;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null, outputFormat = null) => {
|
|
27
|
+
export const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null, outputFormat = null) => {
|
|
28
28
|
let nomerCmd = `nomer ${cmd}`;
|
|
29
29
|
if (properties) {
|
|
30
30
|
nomerCmd = `${nomerCmd} -p ${properties}`;
|
|
@@ -39,7 +39,7 @@ const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null,
|
|
|
39
39
|
return nomerCmd;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const runNomer = (nomerCmd) => {
|
|
42
|
+
export const runNomer = (nomerCmd) => {
|
|
43
43
|
try {
|
|
44
44
|
const result = execSync(nomerCmd, {
|
|
45
45
|
maxBuffer: 4096 * 4096,
|
|
@@ -53,7 +53,7 @@ const runNomer = (nomerCmd) => {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
const runNomerAsync = (nomerCmd) => {
|
|
56
|
+
export const runNomerAsync = (nomerCmd) => {
|
|
57
57
|
const nomerCmdArr = nomerCmd.split(/\s+/)
|
|
58
58
|
const p = spawn(nomerCmdArr[0], nomerCmdArr.slice(1), {
|
|
59
59
|
// maxBuffer: 4096 * 4096
|
|
@@ -61,12 +61,4 @@ const runNomerAsync = (nomerCmd) => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
return p
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
module.exports = {
|
|
67
|
-
getNomerValidateCmd,
|
|
68
|
-
getNomerMatchCmd,
|
|
69
|
-
getNomerSimpleCmd,
|
|
70
|
-
runNomer,
|
|
71
|
-
runNomerAsync
|
|
72
|
-
};
|
|
64
|
+
}
|
package/webpack.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var path = require("path");
|
|
2
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
3
|
-
|
|
4
|
-
module.exports = {
|
|
5
|
-
mode: "production",
|
|
6
|
-
entry: "./src/index.js",
|
|
7
|
-
output: {
|
|
8
|
-
path: path.resolve(__dirname, "dist"),
|
|
9
|
-
filename: "index.js",
|
|
10
|
-
},
|
|
11
|
-
module: {
|
|
12
|
-
rules: [
|
|
13
|
-
{ test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" }
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
target: 'node'
|
|
17
|
-
};
|