forked from isomorphic-git/isomorphic-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·24 lines (22 loc) · 697 Bytes
/
Copy pathcli.js
File metadata and controls
executable file
·24 lines (22 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env node
const fs = require('fs')
const minimisted = require('minimisted')
const git = require('.')
// This really isn't much of a CLI. It's mostly for testing.
// But it's very versatile and works surprisingly well.
minimisted(async function ({ _: [command, ...args], ...opts }) {
try {
const result = await git[command](Object.assign({ fs, dir: '.' }, opts))
if (result === undefined) return
// detect streams
if (typeof result.on === 'function') {
result.pipe(process.stdout)
} else {
console.log(JSON.stringify(result, null, 2))
}
} catch (err) {
process.stderr.write(err.message + '\n')
console.log(err)
process.exit(1)
}
})