package-preview
Version:
Creates a production preview of a package
18 lines • 887 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const findDown = require("find-down");
const path = require("path");
const PACKAGE_PREVIEWS_DIRNAME = '__package_previews__';
async function default_1(target, pkgName) {
// The preview directory should be placed in a directory that doesn't have
// node_modules or packages up in the directory tree.
// Otherwise the package would have access to modules that are not declared
// in its package.json
const filename = await findDown(['node_modules', 'package.json', 'pnpm-workspace.yaml'], { cwd: target });
if (filename === null) {
return path.join(path.dirname(target), PACKAGE_PREVIEWS_DIRNAME, pkgName);
}
return path.join(path.dirname(path.dirname(filename)), PACKAGE_PREVIEWS_DIRNAME, pkgName);
}
exports.default = default_1;
//# sourceMappingURL=getPreviewDir.js.map