Skip to content

Commit

Permalink
😒 renaming reference util to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush2k committed Aug 8, 2016
1 parent 77c7eda commit 7896746
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/content-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _ = require('lodash');
const loader = require('./content-types/load');
const merge = require('./content-types/merge');
const only = require('./content-types/only');
const util = require('./util');
const utils = require('./utils');

/**
* Get single Content Type
Expand All @@ -16,7 +16,7 @@ const util = require('./util');
* @returns {object} content type object
*/
const findCT = (id, types) => {
const ct = util.singleItem('id', id, types);
const ct = utils.singleItem('id', id, types);

if (ct === false) {
throw new Error(`Content type ${id} not found `);
Expand Down
4 changes: 2 additions & 2 deletions lib/content-types/load.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const yaml = require('js-yaml');
const slugify = require('lodash/kebabCase');
const globalConfig = require('config');
const path = require('path');
const util = require('../util');
const utils = require('../utils');


/**
Expand Down Expand Up @@ -111,7 +111,7 @@ const names = types => {
* @returns {array} array of content type's attribute objects
*/
const attributes = (id, types) => {
const filtered = util.singleItem('id', id, types);
const filtered = utils.singleItem('id', id, types);

return filtered ? filtered[0].attributes : false;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/content-types/only.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const merge = require('deepmerge');
const util = require('../util');
const utils = require('../utils');

const only = (type, config) => {
return new Promise((resolve) => {
Expand Down Expand Up @@ -30,8 +30,8 @@ const only = (type, config) => {
inputs.forEach(input => {
instance[input].validation = attribute.inputs[0][input].validation;
instance[input].type = attribute.inputs[0][input].type;
instance[input].id = `${util.splitPop(attribute.inputs[0][input].id, '--')}--${index}`;
instance[input].name = `${util.splitPop(attribute.inputs[0][input].name, '--')}--${index}`;
instance[input].id = `${utils.splitPop(attribute.inputs[0][input].id, '--')}--${index}`;
instance[input].name = `${utils.splitPop(attribute.inputs[0][input].name, '--')}--${index}`;
});

return instance;
Expand Down
2 changes: 1 addition & 1 deletion lib/form/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const stream = require('stream');
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
const utils = require('../util');
const utils = require('../utils');
const globalConfig = require('config');
const formJS = fs.readdirSync(path.join(__dirname, 'js')).map(script => {
return fs.readFileSync(path.join(__dirname, 'js', script));
Expand Down
4 changes: 2 additions & 2 deletions lib/form/validate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const util = require('../util');
const utils = require('../utils');

/*
* @typedef FormInputValues
Expand Down Expand Up @@ -230,7 +230,7 @@ const validate = (raw, type) => {
const values = buildValues(working);
working = working.map(value => {
const result = value;
const plugin = util.singleItem('id', value.plugin, type.attributes);
const plugin = utils.singleItem('id', value.plugin, type.attributes);
const input = {};
const settings = {};

Expand Down
8 changes: 4 additions & 4 deletions tests/utils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import test from 'ava';
import util from '../lib/util.js';
import utils from '../lib/utils.js';
import _ from 'lodash';
import path from 'path';

test('Getplugins works with directory value as string', t => {
const input = {};
_.set(input, 'content.plugins.directory', path.join(process.cwd(), 'fixtures'));
t.is(typeof util.getPlugins(input), 'object');
t.is(typeof utils.getPlugins(input), 'object');
});

test('Getplugins works with directory value as boolean', t => {
const input = {};
_.set(input, 'content.plugins.directory', true);
t.is(typeof util.getPlugins(input), 'object');
t.is(typeof utils.getPlugins(input), 'object');
});

test('Getplugins works with directory value as undefined', t => {
const input = {};
t.is(typeof util.getPlugins(input), 'object');
t.is(typeof utils.getPlugins(input), 'object');
});

0 comments on commit 7896746

Please sign in to comment.