diff --git a/src/commitizen.js b/src/commitizen.js index 018bd681..1f031445 100644 --- a/src/commitizen.js +++ b/src/commitizen.js @@ -2,7 +2,6 @@ import * as adapter from './commitizen/adapter'; import * as cache from './commitizen/cache'; import commit from './commitizen/commit'; -import * as configLoader from './commitizen/configLoader'; import init from './commitizen/init'; import * as staging from './commitizen/staging'; @@ -10,7 +9,6 @@ export { adapter, cache, commit, - configLoader, init, staging }; diff --git a/src/commitizen/configLoader.js b/src/commitizen/configLoader.js deleted file mode 100644 index 02355d78..00000000 --- a/src/commitizen/configLoader.js +++ /dev/null @@ -1,10 +0,0 @@ -import { loader } from '../configLoader'; - -export { load }; - -// Configuration sources in priority order. -var configs = ['.czrc', '.cz.json', 'package.json']; - -function load (config, cwd) { - return loader(configs, config, cwd); -} diff --git a/src/commitizen/init.js b/src/commitizen/init.js index 91ec5b7d..4ff40f85 100644 --- a/src/commitizen/init.js +++ b/src/commitizen/init.js @@ -1,7 +1,7 @@ import childProcess from 'child_process'; import path from 'path'; -import * as configLoader from './configLoader'; import * as adapter from './adapter'; +import * as configLoader from '../configLoader'; let { addPathToAdapterConfig, @@ -15,6 +15,9 @@ export default init; const CLI_PATH = path.normalize(path.join(__dirname, '../../')); +/** Configuration sources in priority order. */ +const LOADER_CONFIGS = ['.czrc', '.cz.json', 'package.json']; + /** * CZ INIT * @@ -63,7 +66,7 @@ function init (repoPath, adapterNpmName, { checkRequiredArguments(repoPath, adapterNpmName); // Load the current adapter config - let adapterConfig = loadAdapterConfig(repoPath); + let adapterConfig = configLoader.loader(LOADER_CONFIGS, null, repoPath); // Get the npm string mappings based on the arguments provided let stringMappings = yarn ? getYarnAddStringMappings(dev, exact, force) : getNpmInstallStringMappings(save, saveDev, saveExact, force); @@ -107,16 +110,3 @@ function checkRequiredArguments (path, adapterNpmName) { throw new Error("The adapter's npm name is required when running init."); } } - -/** - * CONFIG - * Loads and returns the adapter config at key config.commitizen, if it exists - */ -function loadAdapterConfig (cwd) { - let config = configLoader.load(null, cwd); - if (config) { - return config; - } else { - - } -} diff --git a/src/configLoader/loader.js b/src/configLoader/loader.js index ba34f509..a6b63117 100644 --- a/src/configLoader/loader.js +++ b/src/configLoader/loader.js @@ -13,7 +13,7 @@ export default loader; /** * Get content of the configuration file - * @param {String} config - partial path to configuration file + * @param {String|null} config - partial path to configuration file * @param {String} cwd - directory path which will be joined with config argument * @return {Object|undefined} */