diff --git a/index.js b/index.js index 57fa368..eb39bdf 100644 --- a/index.js +++ b/index.js @@ -9,27 +9,10 @@ const fs = require('fs'); const path = require('path'); -const util = require('util'); const ini = require('ini'); const configPath = require('git-config-path'); const expand = require('expand-tilde'); -/** - * Wraps an arbitrary function in a Promise. - * - * @param {Function} `func` The function to be wrapped. - */ - -function promisify(func) { - return function (...args) { - return new Promise((resolve, reject) => { - func(...args, (err, res) => { - err ? reject(err) : resolve(res); - }); - }); - } -} - const read = promisify(fs.readFile); const stat = promisify(fs.stat); @@ -211,6 +194,22 @@ function injectInclude(input, cwd) { return res.join('\n'); } +/** + * Wraps an arbitrary function in a Promise. + * + * @param {Function} `fn` The function to be wrapped. + */ + +function promisify(fn) { + return (...args) => { + return new Promise((resolve, reject) => { + fn(...args, (err, res) => { + err ? reject(err) : resolve(res); + }); + }); + }; +} + /** * Expose `parse` */ diff --git a/test/test.js b/test/test.js index afa074f..9ea2986 100644 --- a/test/test.js +++ b/test/test.js @@ -2,7 +2,6 @@ require('mocha'); const isTravis = process.env.TRAVIS || process.env.CLI; -const fs = require('fs'); const os = require('os'); const assert = require('assert'); const path = require('path'); @@ -12,10 +11,6 @@ const parse = require('..'); const cwd = (...args) => path.resolve(__dirname, ...args); const fixture = name => cwd('fixtures', name); -function read(filepath) { - return fs.readFileSync(path.join(__dirname, filepath), 'utf8'); -} - describe('parse-git-config', function() { describe('async', function() { it('should return a promise when callback is not passed', function(cb) { @@ -48,7 +43,7 @@ describe('parse-git-config', function() { it('should not expand dots in keys in config', function(cb) { parse({ path: fixture('_gitconfig-branch'), expandKeys: true }) .then(config => { - assert.deepEqual(Object.keys(config.branch), ['devel', 'master', '2.0']) + assert.deepEqual(Object.keys(config.branch), ['devel', 'master', '2.0']); cb(); }) .catch(cb);