Skip to content

Commit a1d11c6

Browse files
committed
Improved publish script.
1 parent b0a73b5 commit a1d11c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

publish.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ const { execSync } = require('child_process');
44
const version = JSON.parse(process.env.npm_config_argv).remain[0];
55
const regex = /(?<=^[Vv]|^)(?:(?<major>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<minor>(?:0|[1-9](?:(?:0|[1-9])+)*))[.](?<patch>(?:0|[1-9](?:(?:0|[1-9])+)*))(?:-(?<prerelease>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:0|[1-9](?:(?:0|[1-9])+)*)))*))?(?:[+](?<build>(?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+))(?:[.](?:(?:(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?|(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)(?:[A-Za-z]|-)(?:(?:(?:0|[1-9])|(?:[A-Za-z]|-))+)?)|(?:(?:0|[1-9])+)))*))?)$/;
66

7-
if (!version || !version.match(regex)) {
8-
console.error('Please enter a semantic version. E.g. 1.0.0');
7+
if (!version) {
98
process.exit();
109
}
1110

11+
if (!version.match(regex)) {
12+
console.error('Please enter a semantic version. E.g. 1.0.0');
13+
process.exit();
14+
}
15+
1216
execSync(`npm version ${version}`);
1317
execSync('git push');
1418
execSync('npm publish --access public');

0 commit comments

Comments
 (0)