mirror of
https://github.com/RamonGebben/mergify.git
synced 2026-03-10 08:51:18 +00:00
Add message to inform user config will be overriden
This commit is contained in:
8
index.js
8
index.js
@@ -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));
|
||||
18
lib/checkConfigExists/index.js
Normal file
18
lib/checkConfigExists/index.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user