Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Je committed Oct 14, 2020
1 parent db301ee commit 6069b8b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
45 changes: 45 additions & 0 deletions bump.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { version } from './version.ts';

const p = version.split('.').map(s => parseInt(s))
const versions = [
`${p[0]}.${p[1]}.${p[2] + 1}`,
`${p[0]}.${p[1] + 1}.0`,
`${p[0] + 1}.0.0`,
]

async function ask(question: string = '', stdin = Deno.stdin, stdout = Deno.stdout) {
const buf = new Uint8Array(1024)
await stdout.write(new TextEncoder().encode(question))
const n = <number>await stdin.read(buf)
const answer = new TextDecoder().decode(buf.subarray(0, n))
return answer.trim()
}

async function run(...cmd: string[]) {
const p = Deno.run({
cmd,
stdout: 'piped',
stderr: 'piped'
})
Deno.stdout.write(await p.output())
Deno.stderr.write(await p.stderrOutput())
p.close()
}

async function main() {
const answer = await ask([...versions.map((v, i) => `${i + 1}. v${v}`), 'upgrade to: '].join('\n'))
const v = parseInt(answer)
if (!isNaN(v) && v > 0 && v <= 3) {
const up = versions[v - 1]
if (await ask('are you sure? (y/n) ') === 'y') {
await Deno.writeTextFile('./version.ts', `export const version = '${up}'\n`)
await run('git', 'add', '.', '--all')
await run('git', 'commit', '-m', `v${up}`)
await run('git', 'tag', `v${up}`)
}
}
}

if (import.meta.main) {
main()
}
2 changes: 1 addition & 1 deletion version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = '0.1.9'
export const version = '0.2.0'

0 comments on commit 6069b8b

Please sign in to comment.