Skip to content

Commit

Permalink
refactor: simplify configLoader call
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusU committed May 3, 2020
1 parent 88aa26f commit 468e924
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
2 changes: 0 additions & 2 deletions src/commitizen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
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';

export {
adapter,
cache,
commit,
configLoader,
init,
staging
};
10 changes: 0 additions & 10 deletions src/commitizen/configLoader.js

This file was deleted.

20 changes: 5 additions & 15 deletions src/commitizen/init.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {

}
}
2 changes: 1 addition & 1 deletion src/configLoader/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down

0 comments on commit 468e924

Please sign in to comment.