nodejs-nomer 1.0.9 → 1.0.11

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/dist/index.js CHANGED
@@ -91,9 +91,16 @@ var Nomer = /*#__PURE__*/function () {
91
91
  var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
92
92
  var matcher = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "globi-taxon-cache";
93
93
  var outputFormat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "tsv";
94
- var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt));
94
+ var res = (0, _utils.runNomer)((0, _utils.getNomerMatchCmd)(query, "append", matcher, this.getPropertiesPath(), outputFormat, this.echoOpt), query);
95
95
  return res;
96
96
  }
97
+ }, {
98
+ key: "appendAsync",
99
+ value: function appendAsync() {
100
+ var matcher = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "globi-taxon-cache";
101
+ var outputFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "tsv";
102
+ return (0, _utils.runNomerAsync)("nomer append ".concat(matcher, " -o ").concat(outputFormat));
103
+ }
97
104
  }, {
98
105
  key: "getPropertiesPath",
99
106
  value: function getPropertiesPath() {
package/dist/utils.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
 
3
3
  var _require = require('child_process'),
4
- execSync = _require.execSync;
4
+ execSync = _require.execSync,
5
+ exec = _require.exec;
5
6
  var getNomerValidateCmd = function getNomerValidateCmd() {
6
7
  var filepath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
7
8
  var cmd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "validate-term";
@@ -61,9 +62,19 @@ var runNomer = function runNomer(nomerCmd) {
61
62
  return null;
62
63
  }
63
64
  };
65
+ var runNomerAsync = function runNomerAsync(nomerCmd) {
66
+ var p = exec(nomerCmd, {
67
+ maxBuffer: 4096 * 4096
68
+ });
69
+ return {
70
+ stdin: p.stdin,
71
+ stdout: p.stdout
72
+ };
73
+ };
64
74
  module.exports = {
65
75
  getNomerValidateCmd: getNomerValidateCmd,
66
76
  getNomerMatchCmd: getNomerMatchCmd,
67
77
  getNomerSimpleCmd: getNomerSimpleCmd,
68
- runNomer: runNomer
78
+ runNomer: runNomer,
79
+ runNomerAsync: runNomerAsync
69
80
  };
package/package.json CHANGED
@@ -1,14 +1,18 @@
1
1
  {
2
2
  "name": "nodejs-nomer",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "NodeJS wrapper for nomer",
5
5
  "bin": {
6
6
  "nomer": "./bin/nomer"
7
7
  },
8
+ "config": {
9
+ "nomerVersion": "0.5.7"
10
+ },
8
11
  "main": "index.js",
9
12
  "scripts": {
10
13
  "test": "npm run test",
11
- "build": "babel src -d dist"
14
+ "build": "babel src -d dist",
15
+ "preinstall": "./install_nomer.sh ${npm_package_config_nomerVersion}"
12
16
  },
13
17
  "repository": {
14
18
  "type": "git",
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { runNomer, getNomerSimpleCmd, getNomerValidateCmd, getNomerMatchCmd } from "./utils";
1
+ import { runNomer, runNomerAsync, getNomerSimpleCmd, getNomerValidateCmd, getNomerMatchCmd } from "./utils";
2
2
  import Result from './result'
3
3
  import { getProperties } from "properties-file";
4
4
 
@@ -75,11 +75,16 @@ class Nomer {
75
75
  this.getPropertiesPath(),
76
76
  outputFormat,
77
77
  this.echoOpt
78
- )
78
+ ),
79
+ query
79
80
  );
80
81
  return res;
81
82
  }
82
83
 
84
+ appendAsync(matcher = "globi-taxon-cache", outputFormat = "tsv") {
85
+ return runNomerAsync(`nomer append ${matcher} -o ${outputFormat}`)
86
+ }
87
+
83
88
  getPropertiesPath() {
84
89
  return this.propertiesPath;
85
90
  }
package/src/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- const { execSync } = require('child_process')
1
+ const { execSync, exec } = require('child_process')
2
2
 
3
3
  const getNomerValidateCmd = (filepath = "", cmd = "validate-term", properties = null) => {
4
4
  if (filepath === "") {
@@ -42,7 +42,7 @@ const getNomerSimpleCmd = (cmd = "version", verbose = false, properties = null,
42
42
  const runNomer = (nomerCmd) => {
43
43
  try {
44
44
  const result = execSync(nomerCmd, {
45
- maxBuffer: 4096 * 4096
45
+ maxBuffer: 4096 * 4096,
46
46
  }).toString();
47
47
  if (result) {
48
48
  return result.trimEnd();
@@ -53,9 +53,18 @@ const runNomer = (nomerCmd) => {
53
53
  }
54
54
  }
55
55
 
56
+ const runNomerAsync = (nomerCmd) => {
57
+ const p = exec(nomerCmd, {
58
+ maxBuffer: 4096 * 4096
59
+ })
60
+
61
+ return { stdin: p.stdin, stdout: p.stdout }
62
+ }
63
+
56
64
  module.exports = {
57
65
  getNomerValidateCmd,
58
66
  getNomerMatchCmd,
59
67
  getNomerSimpleCmd,
60
- runNomer
68
+ runNomer,
69
+ runNomerAsync
61
70
  };
package/bin/nomer DELETED
Binary file