Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions modules/utils/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@ async function format(contents: object) {
class Versioner {
localAndExtraModules: { [name: string]: string } = {};
private noTest = false;
private tag = undefined;
noPublish = false;

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

constructor(private version: string) {
if (!version) {
console.error(`usage: ${me}: <version> <extra modules> [--notest]`);
console.error(`usage: ${me}: <version> <extra modules> [--notest] [--tag=<tag>] [--nopublish]`);
process.exit(1);
}
extra.forEach((e, i) => {
if (e === '--notest') {
for (let i = extra.length - 1; i >= 0; i--) {
const e = extra[i];
if (e.startsWith('--tag=')) {
this.tag = e.split('=')[1];
extra.splice(i, 1);
} else if (e === '--notest') {
this.noTest = true;
extra.splice(i, 1);
} else if (e === '--nopublish') {
this.noPublish = true;
extra.splice(i, 1);
} else if (e.startsWith('-')) {
throw Error(`unknown option ${e}; use --notest or --nopublish`);
throw Error(`unknown option ${e}; use --tag=<tag>, --notest or --nopublish`);
}
});
}
}

async doVersion() {
Expand Down Expand Up @@ -91,10 +96,14 @@ class Versioner {
}

async npmPublish(name: string, module: string) {
const publish = ['npm', 'publish'];
if (this.tag) {
publish.push('--tag', this.tag);
}
if (this.noPublish) {
return;
}
await spawnCommand(['npm', 'publish'], module).catch((e) => {
await spawnCommand(publish, module).catch((e) => {
console.error(`npm publish failed for ${name}: ${e}`);
});
}
Expand Down
90 changes: 55 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.