 fs.path = require 'path'
 async = require 'async'
 _ = require 'underscore'
-yaml = require 'js-yaml'
+confert = require 'confert'
 utils = require './utils'
 {unwrap} = utils.string
 

                namespace = fs.path.basename filename, extension             

        {filename, namespace}

readData = (path) ->
    resolvedPath = fs.path.resolve path
    fs.readFileSync resolvedPath, encoding: 'utf8'

parseData = (raw, extension) ->
    switch extension
        when '.json'
            JSON.parse raw
        when '.yml', '.yaml'
            yaml.safeLoad raw
        else
            throw new Error "Context files need to be JSON or YAML."

# REFACTOR: this function can use a more rigorous rethink
merge = (sources...) ->

    for path in paths
        {filename, namespace} = path
        extension = fs.path.extname filename
        path.data = confert fs.path.resolve filename

    merge paths...

