@yao-pkg/pkg-fetch 3.5.13 → 3.5.14

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/lib-es5/index.js CHANGED
@@ -146,9 +146,9 @@ function getNodeVersion(nodeRange) {
146
146
  exports.getNodeVersion = getNodeVersion;
147
147
  function need(opts) {
148
148
  return __awaiter(this, void 0, void 0, function () {
149
- var _a, forceFetch, forceBuild, dryRun, output, nodeRange, _b, platform, arch, nodeVersion, fetched, built, remote, fetchFailed;
150
- return __generator(this, function (_c) {
151
- switch (_c.label) {
149
+ var _a, forceFetch, forceBuild, dryRun, output, nodeRange, _b, platform, arch, nodeVersion, fetched, built, remote, fetchFailed, _c;
150
+ return __generator(this, function (_d) {
151
+ switch (_d.label) {
152
152
  case 0:
153
153
  _a = opts || {}, forceFetch = _a.forceFetch, forceBuild = _a.forceBuild, dryRun = _a.dryRun, output = _a.output, nodeRange = _a.nodeRange;
154
154
  _b = opts || {}, platform = _b.platform, arch = _b.arch;
@@ -178,51 +178,57 @@ function need(opts) {
178
178
  output: output,
179
179
  });
180
180
  remote = (0, places_1.remotePlace)({ arch: arch, nodeVersion: nodeVersion, platform: platform, version: package_json_1.version });
181
- if (!!forceBuild) return [3 /*break*/, 3];
181
+ if (!!forceBuild) return [3 /*break*/, 4];
182
182
  return [4 /*yield*/, exists(fetched)];
183
183
  case 1:
184
- if (!_c.sent()) return [3 /*break*/, 3];
184
+ if (!_d.sent()) return [3 /*break*/, 4];
185
185
  if (dryRun) {
186
186
  return [2 /*return*/, 'exists'];
187
187
  }
188
+ _c = !!process.env.PKG_NODE_PATH;
189
+ if (_c) return [3 /*break*/, 3];
188
190
  return [4 /*yield*/, (0, utils_1.hash)(fetched)];
189
191
  case 2:
190
- if ((_c.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
192
+ _c = (_d.sent()) === expected_1.EXPECTED_HASHES[remote.name];
193
+ _d.label = 3;
194
+ case 3:
195
+ // when node path is set, skip hash check
196
+ if (_c) {
191
197
  return [2 /*return*/, fetched];
192
198
  }
193
199
  log_1.log.info('Binary hash does NOT match. Re-fetching...');
194
200
  fs_extra_1.default.unlinkSync(fetched);
195
- _c.label = 3;
196
- case 3:
197
- if (!!forceFetch) return [3 /*break*/, 5];
198
- return [4 /*yield*/, exists(built)];
201
+ _d.label = 4;
199
202
  case 4:
200
- if (_c.sent()) {
203
+ if (!!forceFetch) return [3 /*break*/, 6];
204
+ return [4 /*yield*/, exists(built)];
205
+ case 5:
206
+ if (_d.sent()) {
201
207
  if (dryRun)
202
208
  return [2 /*return*/, 'exists'];
203
209
  if (forceBuild)
204
210
  log_1.log.info('Reusing base binaries built locally:', built);
205
211
  return [2 /*return*/, built];
206
212
  }
207
- _c.label = 5;
208
- case 5:
209
- if (!!forceBuild) return [3 /*break*/, 9];
213
+ _d.label = 6;
214
+ case 6:
215
+ if (!!forceBuild) return [3 /*break*/, 10];
210
216
  if (dryRun)
211
217
  return [2 /*return*/, 'fetched'];
212
218
  return [4 /*yield*/, download(remote, fetched)];
213
- case 6:
214
- if (!_c.sent()) return [3 /*break*/, 8];
215
- return [4 /*yield*/, (0, utils_1.hash)(fetched)];
216
219
  case 7:
217
- if ((_c.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
220
+ if (!_d.sent()) return [3 /*break*/, 9];
221
+ return [4 /*yield*/, (0, utils_1.hash)(fetched)];
222
+ case 8:
223
+ if ((_d.sent()) === expected_1.EXPECTED_HASHES[remote.name]) {
218
224
  return [2 /*return*/, fetched];
219
225
  }
220
226
  fs_extra_1.default.unlinkSync(fetched);
221
227
  throw (0, log_1.wasReported)('Binary hash does NOT match.');
222
- case 8:
223
- fetchFailed = true;
224
- _c.label = 9;
225
228
  case 9:
229
+ fetchFailed = true;
230
+ _d.label = 10;
231
+ case 10:
226
232
  if (!dryRun && fetchFailed) {
227
233
  log_1.log.info('Not found in remote cache:', JSON.stringify(remote));
228
234
  if (forceFetch) {
@@ -244,8 +250,8 @@ function need(opts) {
244
250
  return [2 /*return*/, 'built'];
245
251
  }
246
252
  return [4 /*yield*/, (0, build_1.default)(nodeVersion, arch, platform, built)];
247
- case 10:
248
- _c.sent();
253
+ case 11:
254
+ _d.sent();
249
255
  return [2 /*return*/, built];
250
256
  }
251
257
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yao-pkg/pkg-fetch",
3
- "version": "3.5.13",
3
+ "version": "3.5.14",
4
4
  "description": "Compiles and stores base binaries for pkg",
5
5
  "main": "lib-es5/index.js",
6
6
  "license": "MIT",
@@ -327,17 +327,23 @@ index 0000000000..a697294fdf
327
327
  + }());
328
328
  +}());
329
329
  diff --git node/lib/internal/modules/cjs/loader.js node/lib/internal/modules/cjs/loader.js
330
- index 451b7c2195..203be65195 100644
330
+ index 451b7c2195..7733dfb3d6 100644
331
331
  --- node/lib/internal/modules/cjs/loader.js
332
332
  +++ node/lib/internal/modules/cjs/loader.js
333
- @@ -234,7 +234,10 @@ function stat(filename) {
333
+ @@ -229,12 +229,16 @@ function wrapModuleLoad(request, parent, isMain) {
334
+ * @param {string} filename Absolute path to the file
335
+ */
336
+ function stat(filename) {
337
+ + const origFilename = filename;
338
+ filename = path.toNamespacedPath(filename);
339
+ if (statCache !== null) {
334
340
  const result = statCache.get(filename);
335
341
  if (result !== undefined) { return result; }
336
342
  }
337
343
  - const result = internalFsBinding.internalModuleStat(filename);
338
344
  + const fs = require('fs');
339
- + const result = fs.existsSync(filename) ?
340
- + (fs.statSync(filename).isDirectory() ? 1 : 0) : -1;
345
+ + const result = fs.existsSync(origFilename) ?
346
+ + (fs.statSync(origFilename).isDirectory() ? 1 : 0) : -1;
341
347
  +
342
348
  if (statCache !== null && result >= 0) {
343
349
  // Only set cache when `internalModuleStat(filename)` succeeds.