massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / node_modules / request-light / build / post-publish.js
1 /*---------------------------------------------------------------------------------------------
2  *  Copyright (c) Microsoft Corporation. All rights reserved.
3  *  Licensed under the MIT License. See License.txt in the project root for license information.
4  *--------------------------------------------------------------------------------------------*/
5
6 const cp = require('child_process');
7 const path = require('path');
8 const fs = require('fs');
9 const readline = require('readline');
10 const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
11
12 function updateNextTag() {
13
14         // read package.json from the current working directory
15         var packageJSON = JSON.parse(fs.readFileSync('package.json').toString());
16         var name = packageJSON.name;
17         var version = packageJSON.version;
18         if (version.indexOf('next') !== -1) {
19                 return;
20         }
21
22         opts = {};
23         opts.stdio = 'inherit';
24
25         console.log(name + ": set 'next' tag to latest version");
26
27         const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
28
29         rl.question('Enter OTP token: ', (token) => {
30                 const result = cp.spawnSync(npm, ['--otp', token, 'dist-tags', 'add', name + '@' + version, 'next'], opts);
31
32                 rl.close();
33
34                 if (result.error || result.status !== 0) {
35                         process.exit(1);
36                 }
37         });
38 }
39
40 updateNextTag();
41