UNPKG

semantic-release-pypi

Version:

semantic-release plugin to publish a python package to PyPI

50 lines 2.17 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { execa } from 'execa'; import path from 'path'; import url from 'url'; export const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); function normalizeVersion(version, options = {}) { return __awaiter(this, void 0, void 0, function* () { const { stdout } = yield spawn('python3', [ '-c', `from packaging.version import Version\nprint(Version('${version}'))`, ], options); return stdout; }); } function setopt(setupPy, command, option, value) { return spawn('python3', [ path.basename(setupPy), 'setopt', `--command=${command}`, `--option=${option}`, `--set-value=${value}`, ], { cwd: path.dirname(setupPy) }); } function pipe(context) { return { stdout: context.stdout, stderr: context.stderr, }; } function spawn(file, args, options) { var _a, _b; const cp = execa(file, args, Object.assign(Object.assign({}, options), { stdout: undefined, stderr: undefined })); if (options === null || options === void 0 ? void 0 : options.stdout) { (_a = cp.stdout) === null || _a === void 0 ? void 0 : _a.pipe(options.stdout, { end: false }); } if (options === null || options === void 0 ? void 0 : options.stderr) { (_b = cp.stderr) === null || _b === void 0 ? void 0 : _b.pipe(options.stderr, { end: false }); } return cp; } export { normalizeVersion, pipe, setopt, spawn }; //# sourceMappingURL=util.js.map