semantic-release-vsce
Version:
semantic-release plugin to package and publish VS Code extensions
43 lines (35 loc) • 971 B
JavaScript
// @ts-check
import SemanticReleaseError from '@semantic-release/error';
import { pathExists, readJson } from 'fs-extra/esm';
import path from 'node:path';
export async function verifyPackage(cwd) {
const packagePath = path.join(cwd, './package.json');
if (!(await pathExists(packagePath))) {
throw new SemanticReleaseError(
`${packagePath} was not found. A \`package.json\` is required to release with vsce.`,
'ENOPKG',
);
}
let packageJson;
try {
packageJson = await readJson(packagePath);
} catch {
throw new SemanticReleaseError(
'The `package.json` seems to be invalid.',
'EINVALIDPKG',
);
}
const { name, publisher } = packageJson;
if (!name) {
throw new SemanticReleaseError(
'No `name` found in `package.json`.',
'ENOPKGNAME',
);
}
if (!publisher) {
throw new SemanticReleaseError(
'No `publisher` found in `package.json`.',
'ENOPUBLISHER',
);
}
}