UNPKG

969 BJavaScriptView Raw
1const prompt = require('prompt');
2const notice = require('../../lib/notice');
3const assertPkg = require('../../lib/package-json').assert;
4const hookBitbucket = require('./hooks/bitbucket').handler;
5const hookGithub = require('./hooks/github').handler;
6
7prompt.colors = false;
8prompt.message = '';
9prompt.delimiter = '';
10
11exports.command = 'hook <name> [command]';
12exports.desc = 'Handle webhook for your VCS';
13// eslint-disable-next-line consistent-return
14exports.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}'.
30Supported VCS systems are: 'bitbucket' and 'github'.
31Exiting.`);
32};