@dotzen/dotzen 0.0.1 → 0.0.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/dist/spec/load.js +11 -1
- package/package.json +1 -1
package/dist/spec/load.js
CHANGED
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.importSpecModule = importSpecModule;
|
|
37
37
|
exports.loadSpec = loadSpec;
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
39
40
|
const jiti_1 = require("jiti");
|
|
40
41
|
const result_1 = require("../result/result");
|
|
41
42
|
/**
|
|
@@ -47,7 +48,16 @@ async function importSpecModule(specPath) {
|
|
|
47
48
|
if (!fs.existsSync(specPath))
|
|
48
49
|
return (0, result_1.err)({ kind: 'ConfigNotFound', path: specPath });
|
|
49
50
|
try {
|
|
50
|
-
|
|
51
|
+
// A scaffolded spec imports `@dotzen/dotzen`, but under `npx` the engine
|
|
52
|
+
// runs from the npx cache while the user's project has no local install —
|
|
53
|
+
// so that bare specifier won't resolve from the spec's location. Alias it
|
|
54
|
+
// to THIS running engine's own barrel (dist/index.js at runtime, or
|
|
55
|
+
// src/index.ts under the test transpiler — extension-less so jiti picks
|
|
56
|
+
// the right one). This is what makes the zero-install `npx` flow work.
|
|
57
|
+
const enginePath = path.join(__dirname, '..', 'index');
|
|
58
|
+
const jiti = (0, jiti_1.createJiti)(__filename, {
|
|
59
|
+
alias: { '@dotzen/dotzen': enginePath },
|
|
60
|
+
});
|
|
51
61
|
const mod = (await jiti.import(specPath));
|
|
52
62
|
const spec = mod.spec;
|
|
53
63
|
if (!Array.isArray(spec))
|