UNPKG

1.02 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const fs = require("fs-extra");
4const http_call_1 = require("http-call");
5// eslint-disable-next-line max-params
6async function run(name, file, version, registry, authorization) {
7 const url = [
8 registry.replace(/\/+$/, ''),
9 name.replace('/', '%2f'), // scoped packages need escaped separator
10 ].join('/');
11 const headers = authorization ? { authorization } : {};
12 await fs.outputJSON(file, { current: version, headers }); // touch file with current version to prevent multiple updates
13 const { body } = await http_call_1.default.get(url, { headers, timeout: 5000 });
14 await fs.outputJSON(file, Object.assign(Object.assign({}, body['dist-tags']), { current: version, authorization }));
15 process.exit(0); // eslint-disable-line unicorn/no-process-exit, no-process-exit
16}
17run(process.argv[2], process.argv[3], process.argv[4], process.argv[5], process.argv[6])
18 .catch(require('@oclif/core/handle'));