Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Apr 26, 2018
1 parent f29fb89 commit 4d88f5e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
9 changes: 5 additions & 4 deletions bin/assignees
Expand Up @@ -97,11 +97,12 @@ program
program
.command('project:disable [owner] [repo]')
.description('disable a project completely')
.action(async (owner, repo) => {
.option('--force', 'mark a project as disabled')
.action(async (owner, repo, { force }) => {
const disableProject = disableProjectTask.configure({ logger });

try {
await disableProject({ owner, repo });
await disableProject({ owner, repo, force });
} catch(e) {
logger.error(chalk.red(e.stack));
process.exitCode = 1;
Expand Down Expand Up @@ -131,7 +132,7 @@ program
program
.command('project:list-owners')
.description('list all the owners in database')
.option('--as-list', 'output as list separated by newlines')
.option('--as-list', 'output as list separated by spaces')
.action(async (options) => {
const listOwners = listOwnersTask.configure({ logger });

Expand All @@ -149,7 +150,7 @@ program
program
.command('project:list-emails')
.description('list all the emails in database')
.option('--as-list', 'output as list separated by newlines')
.option('--as-list', 'output as list separated by spaces')
.action(async (options) => {
const listEmails = listEmailsTask.configure({ logger });

Expand Down
20 changes: 12 additions & 8 deletions tasks/disableProject.js
Expand Up @@ -7,7 +7,7 @@ const User = require('../models/User');
* logger: { info: Function, error: Function },
* }
*/
exports.configure = config => async ({ owner, repo, repository }) => {
exports.configure = config => async ({ owner, repo, repository, force = false }) => {
if (!repository) {
repository = await Repository.findOne({
name: repo,
Expand All @@ -17,7 +17,7 @@ exports.configure = config => async ({ owner, repo, repository }) => {
}

if (!repository) {
config.logger.error(`No project found for owner = "${repository.owner}" and repo = "${repository.name}".`);
config.logger.error(`No project found for "${repository.owner}/${repository.name}".`);
return;
}

Expand All @@ -44,15 +44,19 @@ exports.configure = config => async ({ owner, repo, repository }) => {
repo: repository.name,
id: repository.github_hook_id,
});

await repository.set({
enabled: false,
github_hook_id: undefined,
}).save();
} catch (err) {
config.logger.error(`"${repository.owner}/${repository.name}" has not been disabled because of an error:`);
config.logger.error(err.message || err);
return;

if (!force) {
return;
}
}

await repository.set({
enabled: false,
github_hook_id: undefined,
}).save();

config.logger.info(`${repository.owner}/${repository.name} successfully disabled.`);
};
2 changes: 1 addition & 1 deletion tasks/listEmails.js
Expand Up @@ -11,7 +11,7 @@ exports.configure = config => async (asList) => {
const emails = [...new Set(users.map((r) => r.email).filter((email) => /@/.test(email)))];

if (asList) {
console.log(emails.join('\n'))
console.log(emails.join(' '))
} else {
config.logger.info(inspect(emails));
}
Expand Down
2 changes: 1 addition & 1 deletion tasks/listOwners.js
Expand Up @@ -11,7 +11,7 @@ exports.configure = config => async (asList) => {
const owners = [...new Set(repositories.map((r) => r.owner))];

if (asList) {
console.log(owners.join('\n'))
console.log(owners.join(' '))
} else {
config.logger.info(inspect(owners));
}
Expand Down

0 comments on commit 4d88f5e

Please sign in to comment.