From 192e698dcab189a2045ffe2e0dbe8a3308f12f2c Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sun, 27 Mar 2016 17:08:25 +0200 Subject: [PATCH] Create a util folder --- cli.js | 6 +++--- lib/contributors/index.js | 2 +- lib/generate/formatContributionType.test.js | 2 +- lib/generate/formatContributor.js | 1 - lib/generate/index.js | 2 +- lib/generate/index.test.js | 2 +- lib/init/index.js | 6 +++--- lib/init/initContent.js | 2 +- lib/init/prompt.js | 2 +- lib/{ => util}/configFile.js | 0 lib/{init => util}/git.js | 0 lib/util/index.js | 7 +++++++ lib/{ => util}/markdown.js | 0 13 files changed, 19 insertions(+), 13 deletions(-) rename lib/{ => util}/configFile.js (100%) rename lib/{init => util}/git.js (100%) create mode 100644 lib/util/index.js rename lib/{ => util}/markdown.js (100%) diff --git a/cli.js b/cli.js index 6db9fb4..2ce2ff0 100755 --- a/cli.js +++ b/cli.js @@ -4,16 +4,17 @@ var fs = require('fs'); var path = require('path'); +var yargs = require('yargs'); var init = require('./lib/init'); var generate = require('./lib/generate'); -var markdown = require('./lib/markdown'); +var markdown = require('./lib/util').markdown; var updateContributors = require('./lib/contributors'); var cwd = process.cwd(); var defaultRCFile = path.join(cwd, '.all-contributorsrc'); -var argv = require('yargs') +var argv = yargs .help('help') .alias('h', 'help') .command('generate', 'Generate the list of contributors') @@ -22,7 +23,6 @@ var argv = require('yargs') .usage('Usage: $0 add ') .command('init', 'Prepare the project to be used with this tool') .usage('Usage: $0 init') - .demand(2) .default('files', ['README.md']) .default('contributorsPerLine', 7) .default('contributors', []) diff --git a/lib/contributors/index.js b/lib/contributors/index.js index 1dc6acd..fb3904f 100644 --- a/lib/contributors/index.js +++ b/lib/contributors/index.js @@ -2,7 +2,7 @@ var add = require('./add'); var github = require('./github'); -var configFile = require('../configFile'); +var configFile = require('../util').configFile; module.exports = function addContributor(options, username, contributions, cb) { add(options, username, contributions, github, function (error, contributors) { diff --git a/lib/generate/formatContributionType.test.js b/lib/generate/formatContributionType.test.js index 8e31d2f..c963390 100644 --- a/lib/generate/formatContributionType.test.js +++ b/lib/generate/formatContributionType.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import formatContributionType from './formatContributionType'; import contributors from './fixtures/contributors.json'; +import formatContributionType from './formatContributionType'; const fixtures = () => { const options = { diff --git a/lib/generate/formatContributor.js b/lib/generate/formatContributor.js index cc8b72a..1419f87 100644 --- a/lib/generate/formatContributor.js +++ b/lib/generate/formatContributor.js @@ -1,7 +1,6 @@ 'use strict'; var _ = require('lodash/fp'); - var formatContributionType = require('./formatContributionType'); var avatarTemplate = _.template('![<%= contributor.name %>](<%= contributor.avatar_url %>)'); diff --git a/lib/generate/index.js b/lib/generate/index.js index a224168..7e15749 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -1,9 +1,9 @@ 'use strict'; var _ = require('lodash/fp'); +var injectContentBetween = require('../util').markdown.injectContentBetween; var formatBadge = require('./formatBadge'); var formatContributor = require('./formatContributor'); -var injectContentBetween = require('../markdown').injectContentBetween; var badgeRegex = /\[\!\[All Contributors\]\([a-zA-Z0-9\-\.\/_\:\?=]+\)\]\(\#\w+\)/; diff --git a/lib/generate/index.test.js b/lib/generate/index.test.js index 4edf6b0..03dc057 100644 --- a/lib/generate/index.test.js +++ b/lib/generate/index.test.js @@ -1,6 +1,6 @@ import test from 'ava'; -import generate from './'; import contributors from './fixtures/contributors.json'; +import generate from './'; function fixtures() { const options = { diff --git a/lib/init/index.js b/lib/init/index.js index 1393eb6..0746284 100644 --- a/lib/init/index.js +++ b/lib/init/index.js @@ -2,11 +2,11 @@ var _ = require('lodash/fp'); var series = require('async/series'); - +var util = require('../util'); var prompt = require('./prompt'); -var configFile = require('../configFile'); -var markdown = require('../markdown'); var initContent = require('./initContent'); +var configFile = util.configFile; +var markdown = util.markdown; function injectInFile(file, fn, cb) { markdown.read(file, function (error, content) { diff --git a/lib/init/initContent.js b/lib/init/initContent.js index bc7cb71..73aeabf 100644 --- a/lib/init/initContent.js +++ b/lib/init/initContent.js @@ -1,7 +1,7 @@ 'use strict'; var _ = require('lodash/fp'); -var injectContentBetween = require('../markdown').injectContentBetween; +var injectContentBetween = require('../util').markdown.injectContentBetween; var badgeContent = '[![All Contributors](https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square)](#contributors)'; var listContent = ''; diff --git a/lib/init/prompt.js b/lib/init/prompt.js index e75c427..d50cc0b 100644 --- a/lib/init/prompt.js +++ b/lib/init/prompt.js @@ -3,7 +3,7 @@ var _ = require('lodash/fp'); var inquirer = require('inquirer'); -var getRepoInfo = require('./git'); +var getRepoInfo = require('../util').git; var questions = [{ type: 'input', diff --git a/lib/configFile.js b/lib/util/configFile.js similarity index 100% rename from lib/configFile.js rename to lib/util/configFile.js diff --git a/lib/init/git.js b/lib/util/git.js similarity index 100% rename from lib/init/git.js rename to lib/util/git.js diff --git a/lib/util/index.js b/lib/util/index.js new file mode 100644 index 0000000..305dcee --- /dev/null +++ b/lib/util/index.js @@ -0,0 +1,7 @@ +'use strict'; + +module.exports = { + configFile: require('./configFile'), + git: require('./git'), + markdown: require('./markdown') +}; diff --git a/lib/markdown.js b/lib/util/markdown.js similarity index 100% rename from lib/markdown.js rename to lib/util/markdown.js