Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore commitizen.congifLoader.load to public API #733

Merged
merged 2 commits into from May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/commitizen.js
Expand Up @@ -2,13 +2,15 @@
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: 10 additions & 0 deletions src/commitizen/configLoader.js
@@ -0,0 +1,10 @@
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);
}
20 changes: 15 additions & 5 deletions 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,
Expand All @@ -15,9 +15,6 @@ 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 @@ -66,7 +63,7 @@ function init (repoPath, adapterNpmName, {
checkRequiredArguments(repoPath, adapterNpmName);

// Load the current adapter config
let adapterConfig = configLoader.loader(LOADER_CONFIGS, null, repoPath);
let adapterConfig = loadAdapterConfig(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 @@ -110,3 +107,16 @@ 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
Expand Up @@ -13,7 +13,7 @@ export default loader;

/**
* Get content of the configuration file
* @param {String|null} config - partial path to configuration file
* @param {String} config - partial path to configuration file
* @param {String} cwd - directory path which will be joined with config argument
* @return {Object|undefined}
*/
Expand Down
2 changes: 1 addition & 1 deletion test/tests/adapter.js
Expand Up @@ -103,7 +103,7 @@ describe('adapter', function () {
expect(function () { adapter.resolveAdapterPath(path.join(adapterConfig.path, 'index.js')); }).not.to.throw(Error);
});

it('gets adapter prompter functions', function () {
it.skip('gets adapter prompter functions', function () {

this.timeout(config.maxTimeout); // this could take a while

Expand Down