Add message to inform user config will be overriden

This commit is contained in:
Julien Lengrand-Lambert
2018-04-21 15:02:42 +02:00
parent 2d80965e78
commit a43762b791
2 changed files with 25 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ const { getMergeRequests } = require('./lib/getMergeRequests');
const { printMergeRequest } = require('./lib/printMergeRequest');
const { writeConfig } = require('./lib/writeConfig');
const { readConfig } = require('./lib/readConfig');
const { checkConfigExists } = require('./lib/checkConfigExists');
const UNAUTHORIZED_MESSAGE = '401 Unauthorized';
@@ -95,6 +96,11 @@ const verify = async ({ userId }) => {
}
const configure = async () => {
if(await checkConfigExists()){
console.log(chalk.red.bold('Mergify is already configured. Configuring again will override the existing file.'));
}
try {
const answers = await inquirer.prompt([
{
@@ -172,4 +178,4 @@ const run = async() => {
return program
};
run().then(p => p.parse(process.argv));
run().then(p => p.parse(process.argv));

View File

@@ -0,0 +1,18 @@
const { access, constants } = require('fs');
const { promisify } = require('util');
const accessAsync = promisify(access);
async function checkConfigExists() {
try {
const configFileName = `${__dirname}/../../.config`;
await accessAsync(configFileName, constants.F_OK);
return true;
}
catch(_){
return false;
}
}
module.exports = {
checkConfigExists
};