@nwutils/getter 0.2.0 → 0.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwutils/getter",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Get NW.js and related binaries for Linux, MacOS and Windows.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -26,6 +26,7 @@
26
26
  ],
27
27
  "license": "MIT",
28
28
  "main": "./src/main.js",
29
+ "types": "types",
29
30
  "type": "module",
30
31
  "files": [
31
32
  "LICENSE",
@@ -38,6 +39,7 @@
38
39
  },
39
40
  "scripts": {
40
41
  "lint": "eslint .",
42
+ "type": "tsc",
41
43
  "test": "node --test --experimental-test-coverage --test-coverage-exclude=\"tests/**/*\" \"tests/specs/*.test.js\""
42
44
  },
43
45
  "volta": {
@@ -46,13 +48,17 @@
46
48
  },
47
49
  "dependencies": {
48
50
  "semver": "^7.7.3",
49
- "tar": "^7.5.3",
51
+ "tar": "^7.5.4",
50
52
  "yauzl-promise": "^4.0.0"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@eslint/js": "^9.39.2",
56
+ "@types/node": "^25.0.10",
57
+ "@types/semver": "^7.7.1",
58
+ "@types/yauzl-promise": "^4.0.1",
54
59
  "eslint": "^9.39.2",
55
60
  "eslint-plugin-jsdoc": "^62.1.0",
56
- "globals": "^17.0.0"
61
+ "globals": "^17.0.0",
62
+ "typescript": "^5.9.3"
57
63
  }
58
64
  }
package/src/decompress.js CHANGED
@@ -87,6 +87,7 @@ async function unzip(zippedFile, cacheDir) {
87
87
  for (const symlinkEntry of symlinks) {
88
88
  let entryPathAbs = path.join(cacheDir, symlinkEntry.filename);
89
89
  const readStream = await symlinkEntry.openReadStream();
90
+ /** @type {Buffer[]} */
90
91
  const chunks = [];
91
92
  readStream.on('data', (chunk) => chunks.push(chunk));
92
93
  await new Promise(resolve => readStream.on('end', resolve));
package/src/ffmpeg.js CHANGED
@@ -35,4 +35,5 @@ export default async function ffmpeg(downloadUrl, version, platform, arch, cache
35
35
  );
36
36
 
37
37
  await request(url, ffmpegFileAbs);
38
+ return ffmpegFileAbs;
38
39
  }
package/src/main.js CHANGED
@@ -54,10 +54,13 @@ async function get(options) {
54
54
  || options.version === "lts"
55
55
  ) {
56
56
  options.version = manifestData[options.version].slice(1);
57
- } else if (semver.valid(semver.coerce(options.version))) {
58
- options.version = semver.coerce(options.version).version;
59
57
  } else {
60
- throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version);
58
+ const coerced = semver.coerce(options.version);
59
+ if (coerced && semver.valid(coerced)) {
60
+ options.version = coerced.version;
61
+ } else {
62
+ throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version);
63
+ }
61
64
  }
62
65
 
63
66
  if (options.flavor !== "normal" && options.flavor !== "sdk") {
package/src/node.js CHANGED
@@ -45,4 +45,5 @@ export default async function nw(downloadUrl, version, cacheDir) {
45
45
  );
46
46
 
47
47
  await request(url, nwFileAbs);
48
+ return nwFileAbs;
48
49
  }
package/src/request.js CHANGED
@@ -44,7 +44,7 @@ export default function request(url, filePath) {
44
44
  },
45
45
  (res) => {
46
46
  /* Redirect handling */
47
- if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
47
+ if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
48
48
  cleanup();
49
49
 
50
50
  const redirectedUrl = new URL(res.headers.location, parsedUrl).toString();