diff --git a/engine.js b/engine.js index 24a42b7c..59b70eda 100644 --- a/engine.js +++ b/engine.js @@ -1,8 +1,6 @@ 'format cjs'; var wrap = require('word-wrap'); -var map = require('lodash.map'); -var longest = require('longest'); var chalk = require('chalk'); var filter = function(array) { @@ -33,16 +31,27 @@ var filterSubject = function(subject, disableSubjectLowerCase) { return subject; }; +/** + * @param input {string[]} + * @return {number} + */ +function getLongestLength(input) { + var longest = Object.keys(input).reduce(function(maxLength, key) { + return Math.max(maxLength, key.length); + }, 0); + + return longest + 1; +} + // This can be any kind of SystemJS compatible module. // We use Commonjs here, but ES6 or AMD would do just // fine. module.exports = function(options) { - var types = options.types; - - var length = longest(Object.keys(types)).length + 1; - var choices = map(types, function(type, key) { + var keys = Object.keys(options.types); + var length = getLongestLength(keys); + var choices = keys.map(function(key) { return { - name: (key + ':').padEnd(length) + ' ' + type.description, + name: (key + ':').padEnd(length) + ' ' + options.types[key].description, value: key }; }); diff --git a/package-lock.json b/package-lock.json index 03a50710..dbd798ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,8 +12,6 @@ "chalk": "^4.1.2", "commitizen": "^4.3.1", "conventional-commit-types": "^3.0.0", - "lodash.map": "^4.6.0", - "longest": "^2.0.1", "word-wrap": "^1.2.5" }, "devDependencies": { diff --git a/package.json b/package.json index b93a8ed9..ea30c6b2 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,6 @@ "chalk": "^4.1.2", "commitizen": "^4.3.1", "conventional-commit-types": "^3.0.0", - "lodash.map": "^4.6.0", - "longest": "^2.0.1", "word-wrap": "^1.2.5" }, "devDependencies": {