Files: c51a7c32602d5b5501312e9ad0344b4a93fdd8f8 / bin.js
1648 bytesRaw
1 | |
2 | ':' //; exec "$(command -v node || command -v nodejs)" "$0" "$@" |
3 | // http://unix.stackexchange.com/questions/65235/universal-node-js-shebang |
4 | // vi: ft=javascript |
5 | |
6 | var path = require('path') |
7 | var proc = require('child_process') |
8 | |
9 | main() |
10 | |
11 | function main() { |
12 | switch (path.basename(process.argv[1])) { |
13 | case 'git-remote-ssb': |
14 | return require('git-remote-ssb/git-remote-ssb') |
15 | } |
16 | |
17 | var appName = 'ssb_appname' in process.env ? process.env.ssb_appname : |
18 | proc.spawnSync('git', ['config', 'ssb.appname'], |
19 | {encoding: 'utf8'}).stdout.trim() |
20 | var config = require('ssb-config/inject')(appName) |
21 | |
22 | var cmd = config._.shift() |
23 | if (config.help) |
24 | return require('./lib/help')(cmd) |
25 | if (config.version) |
26 | return version() |
27 | |
28 | switch (cmd) { |
29 | case 'create': |
30 | return require('./lib/create')(config, config._[0], config._[1]) |
31 | case 'fork': |
32 | return require('./lib/fork')(config) |
33 | case 'forks': |
34 | return require('./lib/forks')(config) |
35 | case 'issues': |
36 | return require('./lib/issues')(config) |
37 | case 'prs': |
38 | case 'pull-requests': |
39 | return require('./lib/pull-requests')(config) |
40 | case 'name': |
41 | return require('./lib/name')(config) |
42 | case 'pull-request': |
43 | return require('./lib/pull-request')(config) |
44 | case 'web': |
45 | return require('git-ssb-web/server') |
46 | case 'help': |
47 | return require('./lib/help')(config._[0]) |
48 | case 'version': |
49 | return version() |
50 | case undefined: |
51 | return require('./lib/help')() |
52 | default: |
53 | throw 'No such command \'' + cmd + '\'' |
54 | } |
55 | } |
56 | |
57 | function version() { |
58 | var pkg = require('./package') |
59 | console.log(pkg.name, pkg.version) |
60 | } |
61 |
Built with git-ssb-web