koffi 0.9.20 → 0.9.21

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.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/package.json +2 -1
  3. package/test/test.js +36 -18
package/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
  * [Other platforms](#other-platforms)
7
7
  - [Get started](#get-started)
8
8
  - [Tests](#tests)
9
+ - [Benchmarks](#benchmarks)
9
10
 
10
11
  # Introduction
11
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "0.9.20",
3
+ "version": "0.9.21",
4
4
  "description": "Fast and simple FFI (foreign function interface) for Node.js",
5
5
  "keywords": [
6
6
  "foreign",
@@ -28,6 +28,7 @@
28
28
  "devDependencies": {
29
29
  "chalk": "^4.1.2",
30
30
  "ffi-napi": "^4.0.3",
31
+ "minimatch": "^5.0.1",
31
32
  "node-ssh": "^12.0.3",
32
33
  "ref-napi": "^3.0.3",
33
34
  "ref-struct-di": "^1.1.1"
package/test/test.js CHANGED
@@ -23,13 +23,14 @@ const util = require('util');
23
23
  const { spawn, spawnSync } = require('child_process');
24
24
  const { NodeSSH } = require('node-ssh');
25
25
  const chalk = require('chalk');
26
+ const minimatch = require('minimatch');
26
27
 
27
28
  // Globals
28
29
 
29
30
  let script_dir = null;
30
31
  let root_dir = null;
31
32
 
32
- let machines = [];
33
+ let machines = null;
33
34
  let accelerate = true;
34
35
  let ignore = new Set;
35
36
 
@@ -47,6 +48,7 @@ async function main() {
47
48
  process.chdir(script_dir);
48
49
 
49
50
  let command = test;
51
+ let patterns = [];
50
52
 
51
53
  // Parse options
52
54
  {
@@ -54,19 +56,13 @@ async function main() {
54
56
 
55
57
  if (process.argv.length >= 3 && process.argv[2][0] != '-') {
56
58
  switch (process.argv[2]) {
57
- case 'test': { command = test; } break;
58
- case 'start': { command = start; } break;
59
- case 'stop': { command = stop; } break;
60
- case 'info': { command = info; } break;
61
- case 'ssh': { command = ssh; } break;
62
- case 'reset': { command = reset; } break;
63
-
64
- default: {
65
- throw new Error(`Unknown command '${process.argv[2]}'`);
66
- } break;
59
+ case 'test': { command = test; i++; } break;
60
+ case 'start': { command = start; i++; } break;
61
+ case 'stop': { command = stop; i++; } break;
62
+ case 'info': { command = info; i++; } break;
63
+ case 'ssh': { command = ssh; i++; } break;
64
+ case 'reset': { command = reset; i++; } break;
67
65
  }
68
-
69
- i++;
70
66
  }
71
67
 
72
68
  for (; i < process.argv.length; i++) {
@@ -102,7 +98,7 @@ async function main() {
102
98
  if (arg.startsWith('__') || arg.match(/[\\/\.]/))
103
99
  throw new Error(`Machine name '${arg} is not valid`);
104
100
 
105
- machines.push(arg);
101
+ patterns.push(arg);
106
102
  }
107
103
  }
108
104
  }
@@ -138,15 +134,34 @@ async function main() {
138
134
  }
139
135
  }
140
136
 
141
- if (!machines.length) {
142
- for (let name in machines_map)
143
- machines.push(name);
137
+ if (patterns.length) {
138
+ machines = new Set;
139
+
140
+ for (let pattern of patterns) {
141
+ let re = minimatch.makeRe(pattern);
142
+
143
+ for (let name in machines_map) {
144
+ let machine = machines_map[name];
145
+
146
+ if (name.match(re) || machine.name.match(re))
147
+ machines.add(name);
148
+ }
149
+ }
150
+
151
+ if (!machines.size) {
152
+ console.log('Could not match any machine');
153
+ process.exit(1);
154
+ }
155
+ } else {
156
+ machines = new Set(...Object.keys(machines_map));
144
157
 
145
- if (!machines.length) {
158
+ if (!machines.size) {
146
159
  console.error('Could not detect any machine');
147
160
  process.exit(1);
148
161
  }
149
162
  }
163
+
164
+ machines = Array.from(machines);
150
165
  machines = machines.map(name => {
151
166
  let machine = machines_map[name];
152
167
  if (machine == null) {
@@ -157,6 +172,9 @@ async function main() {
157
172
  return machine;
158
173
  });
159
174
 
175
+ console.log('Machines:', machines.map(machine => machine.name).join(', '));
176
+ console.log();
177
+
160
178
  try {
161
179
  let success = await command();
162
180
  process.exit(!success);