hfs 3.1.2 → 3.1.3

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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "hfs",
9
- "version": "3.1.2",
9
+ "version": "3.1.3",
10
10
  "license": "GPL-3.0",
11
11
  "dependencies": {
12
12
  "@gregoranders/csv": "^0.0.13",
@@ -230,9 +230,9 @@
230
230
  }
231
231
  },
232
232
  "node_modules/@peculiar/utils": {
233
- "version": "2.0.2",
234
- "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.2.tgz",
235
- "integrity": "sha512-lHhrK/1QAXGn0GUYkme7t4zo0mQ5QIp+/8YED6pzu8AQFdjA9bAXeNURAHk4sw7n9i89MMNQVom0LkuuLUZMog==",
233
+ "version": "2.0.3",
234
+ "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz",
235
+ "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==",
236
236
  "license": "MIT",
237
237
  "dependencies": {
238
238
  "tslib": "^2.8.1"
@@ -361,12 +361,12 @@
361
361
  "license": "MIT"
362
362
  },
363
363
  "node_modules/axios": {
364
- "version": "1.15.2",
365
- "resolved": "https://registry.npmjs.org/axios/-/axios-1.15.2.tgz",
366
- "integrity": "sha512-wLrXxPtcrPTsNlJmKjkPnNPK2Ihe0hn0wGSaTEiHRPxwjvJwT3hKmXF4dpqxmPO9SoNb2FsYXj/xEo0gHN+D5A==",
364
+ "version": "1.16.0",
365
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.16.0.tgz",
366
+ "integrity": "sha512-6hp5CwvTPlN2A31g5dxnwAX0orzM7pmCRDLnZSX772mv8WDqICwFjowHuPs04Mc8deIld1+ejhtaMn5vp6b+1w==",
367
367
  "license": "MIT",
368
368
  "dependencies": {
369
- "follow-redirects": "^1.15.11",
369
+ "follow-redirects": "^1.16.0",
370
370
  "form-data": "^4.0.5",
371
371
  "proxy-from-env": "^2.1.0"
372
372
  }
@@ -1908,9 +1908,9 @@
1908
1908
  }
1909
1909
  },
1910
1910
  "node_modules/yaml": {
1911
- "version": "2.8.3",
1912
- "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz",
1913
- "integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==",
1911
+ "version": "2.8.4",
1912
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.4.tgz",
1913
+ "integrity": "sha512-ml/JPOj9fOQK8RNnWojA67GbZ0ApXAUlN2UQclwv2eVgTgn7O9gg9o7paZWKMp4g0H3nTLtS9LVzhkpOFIKzog==",
1914
1914
  "license": "ISC",
1915
1915
  "bin": {
1916
1916
  "yaml": "bin.mjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
package/src/first.js CHANGED
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.quitting = void 0;
6
+ exports.exitCode = exports.quitting = void 0;
7
7
  exports.onProcessExit = onProcessExit;
8
+ exports.quit = quit;
8
9
  exports.onFirstEvent = onFirstEvent;
9
10
  const lodash_1 = __importDefault(require("lodash"));
10
11
  const assert_1 = __importDefault(require("assert"));
@@ -16,13 +17,14 @@ function onProcessExit(cb, order = 10) {
16
17
  return () => cbsOnExit.delete(rec);
17
18
  }
18
19
  exports.quitting = false;
20
+ exports.exitCode = 0;
19
21
  // 'exit' event is handled as the last resort, but it's not compatible with async callbacks
20
- onFirstEvent(process, ['exit', 'SIGQUIT', 'SIGTERM', 'SIGINT', 'SIGHUP'], async (signal) => {
22
+ onFirstEvent(process, ['exit', 'SIGQUIT', 'SIGTERM', 'SIGINT', 'SIGHUP', 'beforeExit'], async (signal) => {
21
23
  console.log('Quitting with signal:', signal || 'unknown');
22
24
  exports.quitting = true;
23
25
  const byOrder = lodash_1.default.groupBy(Array.from(cbsOnExit), 'order'); // this will be inherently ordered because keys are positive integers
24
- for (const recs of Object.values(byOrder))
25
- await Promise.allSettled(recs.map(({ cb }) => {
26
+ for (const recs of Object.values(byOrder)) {
27
+ const ret = Promise.allSettled(recs.map(({ cb }) => {
26
28
  try {
27
29
  return cb(signal);
28
30
  }
@@ -32,9 +34,17 @@ onFirstEvent(process, ['exit', 'SIGQUIT', 'SIGTERM', 'SIGINT', 'SIGHUP'], async
32
34
  return Promise.reject(e);
33
35
  }
34
36
  }));
37
+ if (signal !== 'exit') // exit is sync
38
+ await ret;
39
+ }
40
+ cbsOnExit.clear();
35
41
  console.debug('Process exit');
36
- process.exit(0);
42
+ process.exit(exports.exitCode);
37
43
  });
44
+ function quit(code = 0) {
45
+ exports.exitCode = code;
46
+ process.emit('SIGINT');
47
+ }
38
48
  // keep calling cb in a sync fashion – returning a promise instead would break the code for argv.updating (update.ts)
39
49
  function onFirstEvent(emitter, events, cb) {
40
50
  let already = false;
package/src/update.js CHANGED
@@ -201,7 +201,8 @@ async function update(tagOrUrl = '') {
201
201
  (0, child_process_1.spawnSync)((0, util_os_1.cmdEscape)(newBin), ['--updating', binFile, '--cwd .'], { shell: true, stdio: [0, 1, 2] }); // sync necessary to work on Mac by double-click
202
202
  });
203
203
  console.log("Quitting");
204
- setTimeout(() => process.exit(100)); // non-zero, otherwise some service managers (like Shawl) won't restart the process
204
+ setTimeout(() => (0, first_1.quit)(100), // non-zero, otherwise some service managers (like Shawl) won't restart the process.
205
+ 200); // give time to return (and caller to complete, eg: rest api to reply)
205
206
  }
206
207
  catch (e) {
207
208
  plugins_1.pluginsWatcher.unpause();