reffy 14.2.1 → 14.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/lib/util.js +9 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reffy",
3
- "version": "14.2.1",
3
+ "version": "14.2.2",
4
4
  "description": "W3C/WHATWG spec dependencies exploration companion. Features a short set of tools to study spec references as well as WebIDL term definitions and references found in W3C specifications.",
5
5
  "repository": {
6
6
  "type": "git",
package/src/lib/util.js CHANGED
@@ -61,23 +61,16 @@ function requireFromWorkingDirectory(filename) {
61
61
 
62
62
 
63
63
  /**
64
- * Determine the path to the "node_modules" folder to resolve relative links
65
- * in the ES6 browser lib modules. The path depends on whether Reffy is run
66
- * directly, or installed as a library.
64
+ * Path to the "webidl2" folder to resolve relative links in the ES6 browser
65
+ * lib modules. The path depends on whether Reffy is run directly, or installed
66
+ * as a library.
67
67
  *
68
- * @function
69
- * @return {String} Path to the node_modules folder.
68
+ * Code relies on the "require.resolve" function, but note that, when given a
69
+ * simple module name, that function returns the path to the file targeted by
70
+ * the "main" property in "package.json" which, in the case of the webidl2
71
+ * module, is "dist/webidl2.js".
70
72
  */
71
- function getModulesFolder() {
72
- const rootFolder = path.resolve(__dirname, '../..');
73
- let folder = path.resolve(rootFolder, 'node_modules');
74
- if (existsSync(folder)) {
75
- return folder;
76
- }
77
- folder = path.resolve(rootFolder, '..');
78
- return folder;
79
- }
80
- const modulesFolder = getModulesFolder();
73
+ const webidl2Folder = path.resolve(path.dirname(require.resolve('webidl2')), '..');
81
74
 
82
75
 
83
76
  /**
@@ -381,7 +374,7 @@ async function processSpecification(spec, processFunction, args, options) {
381
374
  body = Buffer.from(browserlib);
382
375
  }
383
376
  else if (request.url.includes(webidl2Path)) {
384
- const file = path.resolve(modulesFolder, 'webidl2',
377
+ const file = path.resolve(webidl2Folder,
385
378
  request.url.substring(request.url.indexOf(webidl2Path) + webidl2Path.length));
386
379
  body = await fs.readFile(file);
387
380
  }