all files / src/configLoader/ getNormalizedConfig.js

88.89% Statements 8/9
91.67% Branches 11/12
100% Functions 1/1
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          50×         15× 12×                 35×      
export default getNormalizedConfig;
 
// Given a config and content, plucks the actual
// settings that we're interested in
function getNormalizedConfig(config, content) {
  
  if(content && (config == 'package.json')) {
 
  // PACKAGE.JSON
 
    // Use the npm config key, be good citizens
    if(content.config && content.config.commitizen) {
      return content.config.commitizen;
    } else if(content.czConfig)  { // Old method, will be deprecated in 3.0.0
    
      // Suppress during test
      Iif(typeof global.it !== 'function')
      {
        console.error("\n********\nWARNING: This repository's package.json is using czConfig. czConfig will be deprecated in Commitizen 3. \nPlease use this instead:\n{\n  \"config\": {\n    \"commitizen\": {\n      \"path\": \"./path/to/adapter\"\n    }\n  }\n}\nFor more information, see: http://commitizen.github.io/cz-cli/\n********\n"); 
      }
      return content.czConfig;
    }
  } else {
    // .cz.json or .czrc 
    return content;
  }
    
}