| 99 | } |
| 100 | |
| 101 | function getConfig() { |
| 102 | var configPath = options.config && |
| 103 | path.resolve(process.cwd(), options.config) || |
| 104 | Comb.getCustomConfigPath(); |
| 105 | |
| 106 | var config; |
| 107 | if (!fs.existsSync(configPath)) { |
| 108 | config = require('../config/csscomb.json'); |
| 109 | } else if (configPath.match(/\.css$/)) { |
| 110 | config = Comb.detectInFile(configPath); |
| 111 | } else { |
| 112 | config = Comb.getCustomConfig(configPath); |
| 113 | } |
| 114 | |
| 115 | if (!config) { |
| 116 | const errorMessage = Errors.configParsingError(configPath); |
| 117 | process.stderr.write(errorMessage); |
| 118 | process.exit(1); |
| 119 | } |
| 120 | |
| 121 | applyTemplate(config); |
| 122 | if (options.verbose) config.verbose = options.verbose; |
| 123 | if (options.lint) config.lint = options.lint; |
| 124 | |
| 125 | return config; |
| 126 | } |
| 127 | |
| 128 | function applyTemplate(config) { |
| 129 | if (!config.template) return; |