11import childProcess from 'child_process' ;
22import path from 'path' ;
3- import * as configLoader from './configLoader' ;
43import * as adapter from './adapter' ;
4+ import * as configLoader from '../configLoader' ;
55
66let {
77 addPathToAdapterConfig,
@@ -15,6 +15,9 @@ export default init;
1515
1616const 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- }
0 commit comments