8000 Add a command to list owners · TailorDev/assignees@b1c6cc2 · GitHub
[go: up one dir, main page]

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

Commit

Permalink
Add a command to list owners
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Apr 26, 2018
1 parent 1f670e3 commit b1c6cc2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bin/assignees
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const listUserFeaturesTask = require('../tasks/listUserFeatures');
const updateUserFeatureTask = require('../tasks/updateUserFeature');
const disableProjectTask = require('../tasks/disableProject');
const disableProjectsTask = require('../tasks/disableProjects');
const listOwnersTask = require('../tasks/listOwners');

const updateUserFeatureAction = operation => async (username, feature) => {
const updateUserFeature = updateUserFeatureTask.configure({ logger });
Expand Down Expand Up @@ -126,6 +127,23 @@ program
})
;

program
.command('project:list-owners')
.description('list all the owners in database')
.action(async () => {
const listOwners = listOwnersTask.configure({ logger });

try {
await listOwners();
} catch(e) {
logger.error(chalk.red(e.stack));
process.exitCode = 1;
} finally {
mongoose.connection.close();
}
})
;

program.parse(process.argv);

if (!program.args.length) {
Expand Down
14 changes: 14 additions & 0 deletions tasks/listOwners.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Repository = require('../models/Repository');
const inspect = require('../helpers/inspect');

/**
* config = {
* logger: { info: Function, error: Function },
* }
*/
exports.configure = config => async (username) => {
const repositories = await Repository.find().catch([]);
const owners = [...new Set(repositories.map((r) => r.owner))];

config.logger.info(inspect(owners));
};

0 comments on commit b1c6cc2

Please sign in to comment.
0