-
Notifications
You must be signed in to change notification settings - Fork 41
/
get.ts
64 lines (52 loc) · 1.8 KB
/
get.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* ./src/commands/wardrobe/get.ts
* penguins-eggs v.10.0.0 / ecmascript 2020
* author: Piero Proietti
* email: piero.proietti@gmail.com
* license: MIT
*/
import { Args, Command, Flags } from '@oclif/core'
import { basename } from 'node:path'
import Utils from '../../classes/utils.js'
// libraries
import { exec } from '../../lib/utils.js'
/**
*
*/
export default class Get extends Command {
static args = {
repo: Args.string({ description: 'repository to get', name: 'repo', required: false })
}
// static args ={name: 'repo', description: 'repository to get', required: false}
static description = 'get warorobe'
static examples = ['eggs wardrobe get', 'eggs wardrobe get your-wardrobe']
static flags = {
help: Flags.help({ char: 'h' }),
verbose: Flags.boolean({ char: 'v' })
}
async run(): Promise<void> {
const { args, flags } = await this.parse(Get)
let verbose = false
if (flags.verbose) {
verbose = true
}
const echo = Utils.setEcho(verbose)
Utils.titles(this.id + ' ' + this.argv)
let repo = 'https://github.com/pieroproietti/penguins-wardrobe'
if (this.argv['0'] !== undefined) {
repo = this.argv['0']
}
// No sudo for get
if (process.getuid && process.getuid() === 0) {
Utils.warning('You must run: eggs wardrobe get without sudo')
process.exit(0)
}
const wardrobe = basename(repo) // ~/.eggs-wardrobe
// git clone -b <branchname> --single-branch
// const result = await exec(`git clone -b devel --single-branch --depth 1 ${repo} ${await Utils.wardrobe()}`)
const result = await exec(`git clone --single-branch --depth 1 ${repo} ${await Utils.wardrobe()}`)
if (result.code === 0) {
Utils.warning(`you get new wardrobe from repo: ${repo} in ${await Utils.wardrobe()}`)
}
}
}