qatools-cli 1.3.1 → 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/package.json +1 -1
- package/qatools.js +12 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qatools-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "CLI for QA Tools — requirements, epics, sprints, sessions, App Context sync, project agenda. The companion to qa-tools.com.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"release": "npm version patch --no-git-tag-version && npm publish",
|
package/qatools.js
CHANGED
|
@@ -724,11 +724,18 @@ async function latestPublishedVersion() {
|
|
|
724
724
|
if (c.latest && Date.now() - c.checkedAt < 3600 * 1000) return c.latest; // cli.self-upgrade: a new version is noticed within the hour
|
|
725
725
|
} catch {}
|
|
726
726
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const
|
|
727
|
+
// Not fetch: its keep-alive socket can still be closing when a command calls process.exit, and on Windows libuv
|
|
728
|
+
// then aborts ("Assertion failed: !(handle->flags & UV_HANDLE_CLOSING)", exit 0xC0000409). agent:false closes
|
|
729
|
+
// the connection with the response.
|
|
730
|
+
const url = new URL(process.env.QATOOLS_UPDATE_URL || "https://registry.npmjs.org/qatools-cli/latest");
|
|
731
|
+
const body = await new Promise((resolve, reject) => {
|
|
732
|
+
const req = require(url.protocol === "http:" ? "http" : "https").get(url, { agent: false, headers: { accept: "application/json" } }, (res) => {
|
|
733
|
+
let s = ""; res.setEncoding("utf8"); res.on("data", d => s += d); res.on("end", () => resolve(s)); res.on("error", reject);
|
|
734
|
+
});
|
|
735
|
+
req.setTimeout(2000, () => req.destroy(new Error("timeout")));
|
|
736
|
+
req.on("error", reject);
|
|
737
|
+
});
|
|
738
|
+
const latest = JSON.parse(body).version;
|
|
732
739
|
if (latest) try { fs.writeFileSync(file, JSON.stringify({ checkedAt: Date.now(), latest })); } catch {}
|
|
733
740
|
return latest || null;
|
|
734
741
|
} catch { return null; }
|