mirror of
https://github.com/zhigang1992/velociraptor.git
synced 2026-04-29 05:05:30 +08:00
Improve version tag management
This commit is contained in:
2
cli.ts
2
cli.ts
@@ -12,7 +12,7 @@ if (import.meta.main) {
|
||||
const args = Deno.args;
|
||||
if (args.length > 0 && args[0].startsWith("-")) {
|
||||
try {
|
||||
handleOption(args[0]);
|
||||
await handleOption(args[0]);
|
||||
} catch (e) {
|
||||
log.error(e.message);
|
||||
Deno.exit(1);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "velociraptor",
|
||||
"version": "1.0.0-beta.1",
|
||||
"replaceVersion": [
|
||||
"src/options.ts"
|
||||
"src/version.ts"
|
||||
],
|
||||
"signGitTag": true
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { bold } from "../deps.ts";
|
||||
|
||||
type Action = () => void;
|
||||
type Action = () => void | Promise<void>;
|
||||
|
||||
const options = new Map<string, Action>();
|
||||
|
||||
@@ -35,15 +35,19 @@ Run ${bold("vr")} without arguments to see a list of available scripts.`);
|
||||
registerOption({
|
||||
name: "--version",
|
||||
alias: "-v",
|
||||
action: () => {
|
||||
console.log("1.0.0-beta.1");
|
||||
action: async () => {
|
||||
const { version } = await import("./version.ts");
|
||||
console.log(version);
|
||||
},
|
||||
});
|
||||
|
||||
export function handleOption(option: string) {
|
||||
export async function handleOption(option: string) {
|
||||
if (options.has(option)) {
|
||||
const action = options.get(option);
|
||||
if (action && action.call) action();
|
||||
if (action && action.call) {
|
||||
const ret = action();
|
||||
if (ret instanceof Promise) await ret;
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown option ${option}`);
|
||||
}
|
||||
|
||||
1
src/version.ts
Normal file
1
src/version.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const version = "1.0.0-beta.1";
|
||||
Reference in New Issue
Block a user