Skip to content

Commit 8b65522

Browse files
authored
Version/2.2 (#86)
* add --tag to versioning * 2.2.0
1 parent cbd6535 commit 8b65522

File tree

2 files changed

+70
-41
lines changed

2 files changed

+70
-41
lines changed

modules/utils/src/version.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,31 @@ async function format(contents: object) {
1313
class Versioner {
1414
localAndExtraModules: { [name: string]: string } = {};
1515
private noTest = false;
16+
private tag = undefined;
1617
noPublish = false;
1718

1819
haibunPackageVersions: { [dep: string]: string } = {};
1920

2021
constructor(private version: string) {
2122
if (!version) {
22-
console.error(`usage: ${me}: <version> <extra modules> [--notest]`);
23+
console.error(`usage: ${me}: <version> <extra modules> [--notest] [--tag=<tag>] [--nopublish]`);
2324
process.exit(1);
2425
}
25-
extra.forEach((e, i) => {
26-
if (e === '--notest') {
26+
for (let i = extra.length - 1; i >= 0; i--) {
27+
const e = extra[i];
28+
if (e.startsWith('--tag=')) {
29+
this.tag = e.split('=')[1];
30+
extra.splice(i, 1);
31+
} else if (e === '--notest') {
2732
this.noTest = true;
2833
extra.splice(i, 1);
2934
} else if (e === '--nopublish') {
3035
this.noPublish = true;
3136
extra.splice(i, 1);
3237
} else if (e.startsWith('-')) {
33-
throw Error(`unknown option ${e}; use --notest or --nopublish`);
38+
throw Error(`unknown option ${e}; use --tag=<tag>, --notest or --nopublish`);
3439
}
35-
});
40+
}
3641
}
3742

3843
async doVersion() {
@@ -91,10 +96,14 @@ class Versioner {
9196
}
9297

9398
async npmPublish(name: string, module: string) {
99+
const publish = ['npm', 'publish'];
100+
if (this.tag) {
101+
publish.push('--tag', this.tag);
102+
}
94103
if (this.noPublish) {
95104
return;
96105
}
97-
await spawnCommand(['npm', 'publish'], module).catch((e) => {
106+
await spawnCommand(publish, module).catch((e) => {
98107
console.error(`npm publish failed for ${name}: ${e}`);
99108
});
100109
}

package-lock.json

Lines changed: 55 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)