'use babel'

import FS from 'fs'
import Path from 'path'
import {DEFAULT_CONFIG, CONFIG_FILE_NAME} from '../defaults'

export function getConfig(root) {
  const configPath = Path.join(root, CONFIG_FILE_NAME)

  let config = Object.assign({}, DEFAULT_CONFIG)
  try {
    FS.accessSync(configPath, FS.R_OK)
    const contents = FS.readFileSync(configPath)
    try {
      Object.assign(config, JSON.parse(contents))
    } catch (_) {
      throw new Error(`Malformed configuration file located at ${configPath}`)
    }
  } catch (_) {}

  return config
}

@@ -10,27 +10,20 @@
 l'%0A%0A
-import FS from 'fs'
+/* @flow */%0A
 %0Aimp
@@ -54,25 +54,86 @@
 ort 
-%7BDEFAULT_CONFIG, 
+type %7BUcompiler$Config%7D from '../types'%0Aimport %7Bread%7D from './common'%0Aimport %7B
 CONF
@@ -173,16 +173,22 @@
 %0Aexport 
+async 
 function
@@ -202,13 +202,53 @@
 fig(
-root)
+directory: string): Promise%3CUcompiler$Config%3E
  %7B%0A 
@@ -281,12 +281,17 @@
 oin(
-root
+directory
 , CO
@@ -310,216 +310,62 @@
 ME)%0A
-%0A  let config = Object.assign(%7B%7D, DEFAULT_CONFIG)%0A  try %7B%0A    FS.accessSync(configPath, FS.R_OK)%0A    const contents = FS.readFileSync(configPath)%0A    try %7B%0A      Object.assign(config, JSON.parse(contents))%0A  
+  try %7B%0A    return JSON.parse(await read(configPath))%0A
   %7D 
@@ -376,18 +376,16 @@
 h (_) %7B%0A
-  
     thro
@@ -407,16 +407,21 @@
 lformed 
+JSON 
 configur
@@ -431,18 +431,11 @@
 on f
-ile locate
+oun
 d at
@@ -457,44 +457,8 @@
 )%0A  
- 
- %7D%0A  %7D catch (_) %7B%7D%0A%0A  return config
+%7D
 %0A%7D%0A

Add getConfig helper