const assert = require('assert')
const path = require('path')
const Config = require('./models/config')
const util = require('./util')

function loadConfig (configPath) {
  const options = {}
  const base = options.base = path.dirname(configPath)
  const config = loadConfigFile(configPath)

  assert(config.taskFile, '"taskFile" must be specified in config file.')

  if (config.preset) {
    const presetPath = resolvePresetPath(config.preset, base)
    options.preset = loadConfig(presetPath)
  }

  const tasks = require(path.resolve(base, config.taskFile))

  return new Config(config, tasks, options)
}
module.exports = loadConfig

function loadConfigFile (configPath) {
  const ext = path.extname(configPath)
  if (ext !== '.js' && ext !== '.json') {
    throw new Error(path.basename(configPath) + ' is non-supported file format.')
  }

  return require(path.resolve(configPath))
}

function resolvePresetPath (preset, base) {
  if (!util.isLocalPath(preset)) {
    return require.resolve(preset)
  }
  return require.resolve(path.resolve(base, preset))
}

@@ -713,19 +713,28 @@
 th)%0A
-  if (
+%0A  assert(%0A    
 ext 
-!
+=
 == '
@@ -742,16 +742,16 @@
 js' 
-&&
+%7C%7C
  ext 
-!
+=
 == '
@@ -760,32 +760,14 @@
 son'
-) %7B%0A    throw new Error(
+,%0A    
 path
@@ -822,21 +822,20 @@
 format.'
-)
 %0A  
-%7D
+)
 %0A%0A  retu

Use assert module for assertion