Skip to content

Commit

Permalink
Merge d48649c into b4ffada
Browse files Browse the repository at this point in the history
  • Loading branch information
jlengrand committed Apr 27, 2018
2 parents b4ffada + d48649c commit d7207ae
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
23 changes: 20 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { configure } = require('./lib/commands/configure');
const { verify } = require('./lib/commands/verify');
const { getAllAssigned } = require('./lib/commands/getAllAssigned');
const { getAllSubmitted } = require('./lib/commands/getAllSubmitted');

const { disableCertificateVerification } = require('./lib/options/disableCertificateVerification');
const { readConfig } = require('./lib/utils/readConfig');

program
Expand All @@ -29,7 +29,14 @@ const commands = [
{
trigger: 'configure',
description: 'Setup or update required config',
fn: configure
fn: configure,
options: [
{
trigger: '-s --self-signed',
description: 'disables the verification of certificates when configuring mergify',
fn: disableCertificateVerification
}
]
},
{
trigger: 'verify',
Expand All @@ -52,11 +59,21 @@ const run = async() => {
await verify();
}

commands.forEach(({ trigger, description, fn }) => {
commands.forEach(({ trigger, description, fn, options }) => {
program
.command(trigger)
.description(description)
.action((...args) => fn(config, ...args));

if(options && options.length > 0){
options.forEach(
(option) => {
program.commands[program.commands.length - 1]
.option(option.trigger, option.description, option.fn);
}
);
}

});

return program;
Expand Down
12 changes: 12 additions & 0 deletions lib/options/disableCertificateVerification/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { logger } = require('../../utils/logger');
const chalk = require('chalk');

const disableCertificateVerification = async() => {
logger.log(chalk.red.bold('⚠️ Disabling certificate verification. This is unsafe and should only be used as last resort.'));
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
return;
};

module.exports = {
disableCertificateVerification
};

0 comments on commit d7207ae

Please sign in to comment.