semantic-release-yarn
Version:
semantic-release plugin to publish a npm package with yarn
22 lines (21 loc) • 636 B
JavaScript
import { resolve } from "node:path";
import { getImplementation } from "./container.js";
import { getError } from "./get-error.js";
export async function getPkg({ pkgRoot }, { cwd }) {
const readPackage = await getImplementation("readPackage");
try {
const pkg = await readPackage({
cwd: pkgRoot ? resolve(cwd, String(pkgRoot)) : cwd,
});
if (!pkg.name) {
throw getError("ENOPKGNAME", undefined);
}
return pkg;
}
catch (error) {
if (error.code === "ENOENT") {
throw getError("ENOPKG", undefined);
}
throw error;
}
}