nodejs-nomer 1.0.9 → 1.1.0

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/DEVELOPMENT.md ADDED
@@ -0,0 +1,17 @@
1
+ # DEVELOPMENT
2
+
3
+ Build:
4
+ `npm run build`
5
+
6
+ Link:
7
+
8
+ `npm link`
9
+
10
+ Use package for testing:
11
+ `npm link nodejs-nomer`
12
+
13
+ Run `script.js`
14
+ `node script.js`
15
+
16
+ # PUBLISH
17
+
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,9 @@
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,
6
+ spawn = _require.spawn;
5
7
  var getNomerValidateCmd = function getNomerValidateCmd() {
6
8
  var filepath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
7
9
  var cmd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "validate-term";
@@ -61,9 +63,18 @@ var runNomer = function runNomer(nomerCmd) {
61
63
  return null;
62
64
  }
63
65
  };
66
+ var runNomerAsync = function runNomerAsync(nomerCmd) {
67
+ var nomerCmdArr = nomerCmd.split(/\s+/);
68
+ var p = spawn(nomerCmdArr[0], nomerCmdArr.slice(1), {
69
+ // maxBuffer: 4096 * 4096
70
+ shell: true
71
+ });
72
+ return p;
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.1.0",
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, spawn } = 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,20 @@ const runNomer = (nomerCmd) => {
53
53
  }
54
54
  }
55
55
 
56
+ const runNomerAsync = (nomerCmd) => {
57
+ const nomerCmdArr = nomerCmd.split(/\s+/)
58
+ const p = spawn(nomerCmdArr[0], nomerCmdArr.slice(1), {
59
+ // maxBuffer: 4096 * 4096
60
+ shell: true
61
+ })
62
+
63
+ return p
64
+ }
65
+
56
66
  module.exports = {
57
67
  getNomerValidateCmd,
58
68
  getNomerMatchCmd,
59
69
  getNomerSimpleCmd,
60
- runNomer
70
+ runNomer,
71
+ runNomerAsync
61
72
  };
package/bin/nomer DELETED
Binary file