@theme-registry/refract 0.1.5 → 0.1.6
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/dist/build.cjs.js +1 -1
- package/dist/build.cjs.js.map +1 -1
- package/dist/build.esm.js +1 -1
- package/dist/build.esm.js.map +1 -1
- package/dist/cli.js +15 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ var node_url = require('node:url');
|
|
|
9
9
|
var node_os = require('node:os');
|
|
10
10
|
var node_readline = require('node:readline');
|
|
11
11
|
|
|
12
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
12
13
|
/**
|
|
13
14
|
* Build-layer path + transpile helpers (Node-only).
|
|
14
15
|
*
|
|
@@ -21,8 +22,21 @@ var node_readline = require('node:readline');
|
|
|
21
22
|
* and this module resolves them against the discovered package root — working the SAME way in-repo
|
|
22
23
|
* (root = repo root) and installed (root = the installed package dir).
|
|
23
24
|
*/
|
|
25
|
+
/**
|
|
26
|
+
* This module's own directory, in **both** bundle formats.
|
|
27
|
+
*
|
|
28
|
+
* `__dirname` only exists in the CJS build. The `./build` subpath also ships an ESM bundle, and
|
|
29
|
+
* defaulting to a bare `__dirname` made every ESM consumer of this layer throw `__dirname is not
|
|
30
|
+
* defined` the moment it reached package-root discovery — `runInit`, `runCreate`, `runSkillsInstall`.
|
|
31
|
+
* It went unnoticed because the only consumer was refract's own CLI, which is bundled as CJS.
|
|
32
|
+
*
|
|
33
|
+
* `typeof` guards rather than a feature test, because referencing an undeclared `__dirname` in ESM
|
|
34
|
+
* would be a ReferenceError. Rollup rewrites `import.meta.url` for the CJS output, so the fallback
|
|
35
|
+
* expression is valid in both.
|
|
36
|
+
*/
|
|
37
|
+
const moduleDir = () => typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href))));
|
|
24
38
|
/** Walk up from `startDir` to the first ancestor that contains a `package.json`. */
|
|
25
|
-
const findPackageRoot = (startDir =
|
|
39
|
+
const findPackageRoot = (startDir = moduleDir()) => {
|
|
26
40
|
let dir = startDir;
|
|
27
41
|
for (;;) {
|
|
28
42
|
if (node_fs.existsSync(node_path.join(dir, "package.json")))
|