File: post-publish.js

package info (click to toggle)
node-vscode-lsp 1.0.0~git20230424.1320922-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,140 kB
  • sloc: javascript: 451; sh: 41; makefile: 23
file content (40 lines) | stat: -rw-r--r-- 1,279 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

const cp = require('child_process');
const path = require('path');
const fs = require('fs');
const readline = require('readline');
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';

function updateNextTag() {

	// read package.json from the current working directory
	var packageJSON = JSON.parse(fs.readFileSync('package.json').toString());
	var name = packageJSON.name;
	var version = packageJSON.version;
	if (version.indexOf('next') !== -1) {
		return;
	}

	opts = {};
	opts.stdio = 'inherit';

	console.log(name + ": set 'next' tag to latest version");

	const rl = readline.createInterface({ input: process.stdin, output: process.stdout });

	rl.question('Enter OTP token: ', (token) => {
		const result = cp.spawnSync(npm, ['--otp', token, 'dist-tags', 'add', name + '@' + version, 'next'], opts);

		rl.close();

		if (result.error || result.status !== 0) {
			process.exit(1);
		}
	});
}

updateNextTag();