Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 468e924

Browse filesBrowse files
committed
refactor: simplify configLoader call
1 parent 88aa26f commit 468e924
Copy full SHA for 468e924

4 files changed

+6-28Lines changed: 6 additions & 28 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/commitizen.js‎

Copy file name to clipboardExpand all lines: src/commitizen.js
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
import * as adapter from './commitizen/adapter';
33
import * as cache from './commitizen/cache';
44
import commit from './commitizen/commit';
5-
import * as configLoader from './commitizen/configLoader';
65
import init from './commitizen/init';
76
import * as staging from './commitizen/staging';
87

98
export {
109
adapter,
1110
cache,
1211
commit,
13-
configLoader,
1412
init,
1513
staging
1614
};
Collapse file

‎src/commitizen/configLoader.js‎

Copy file name to clipboardExpand all lines: src/commitizen/configLoader.js
-10Lines changed: 0 additions & 10 deletions
This file was deleted.
Collapse file

‎src/commitizen/init.js‎

Copy file name to clipboardExpand all lines: src/commitizen/init.js
+5-15Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import childProcess from 'child_process';
22
import path from 'path';
3-
import * as configLoader from './configLoader';
43
import * as adapter from './adapter';
4+
import * as configLoader from '../configLoader';
55

66
let {
77
addPathToAdapterConfig,
@@ -15,6 +15,9 @@ export default init;
1515

1616
const CLI_PATH = path.normalize(path.join(__dirname, '../../'));
1717

18+
/** Configuration sources in priority order. */
19+
const LOADER_CONFIGS = ['.czrc', '.cz.json', 'package.json'];
20+
1821
/**
1922
* CZ INIT
2023
*
@@ -63,7 +66,7 @@ function init (repoPath, adapterNpmName, {
6366
checkRequiredArguments(repoPath, adapterNpmName);
6467

6568
// Load the current adapter config
66-
let adapterConfig = loadAdapterConfig(repoPath);
69+
let adapterConfig = configLoader.loader(LOADER_CONFIGS, null, repoPath);
6770

6871
// Get the npm string mappings based on the arguments provided
6972
let stringMappings = yarn ? getYarnAddStringMappings(dev, exact, force) : getNpmInstallStringMappings(save, saveDev, saveExact, force);
@@ -107,16 +110,3 @@ function checkRequiredArguments (path, adapterNpmName) {
107110
throw new Error("The adapter's npm name is required when running init.");
108111
}
109112
}
110-
111-
/**
112-
* CONFIG
113-
* Loads and returns the adapter config at key config.commitizen, if it exists
114-
*/
115-
function loadAdapterConfig (cwd) {
116-
let config = configLoader.load(null, cwd);
117-
if (config) {
118-
return config;
119-
} else {
120-
121-
}
122-
}
Collapse file

‎src/configLoader/loader.js‎

Copy file name to clipboardExpand all lines: src/configLoader/loader.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default loader;
1313

1414
/**
1515
* Get content of the configuration file
16-
* @param {String} config - partial path to configuration file
16+
* @param {String|null} config - partial path to configuration file
1717
* @param {String} cwd - directory path which will be joined with config argument
1818
* @return {Object|undefined}
1919
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.