1 | const prompt = require('prompt');
|
2 | const notice = require('../../lib/notice');
|
3 | const assertPkg = require('../../lib/package-json').assert;
|
4 | const hookBitbucket = require('./hooks/bitbucket').handler;
|
5 | const hookGithub = require('./hooks/github').handler;
|
6 |
|
7 | prompt.colors = false;
|
8 | prompt.message = '';
|
9 | prompt.delimiter = '';
|
10 |
|
11 | exports.command = 'hook <name> [command]';
|
12 | exports.desc = 'Handle webhook for your VCS';
|
13 |
|
14 | exports.handler = (argv) => {
|
15 | const { siteName } = argv;
|
16 | if (!siteName) {
|
17 | console.log('This project is not initialised. Did you forget to \'linc init\'?');
|
18 | process.exit(255);
|
19 | }
|
20 |
|
21 | assertPkg();
|
22 |
|
23 | notice();
|
24 |
|
25 | const { name } = argv;
|
26 | if (name === 'bitbucket') return hookBitbucket(argv);
|
27 | if (name === 'github') return hookGithub(argv);
|
28 |
|
29 | console.log(`Sorry, I don't recognise the VCS system '${name}'.
|
30 | Supported VCS systems are: 'bitbucket' and 'github'.
|
31 | Exiting.`);
|
32 | };
|