const fs = require('fs')
const mkdirp = require('mkdirp')
const { hotelDir, confFile } = require('./common')

// Create dir
mkdirp.sync(hotelDir)

// Defaults
const defaults = {
  port: 2000,
  host: '127.0.0.1',
  timeout: 5000,
  tld: 'dev',
  // Replace with your network proxy IP (1.2.3.4:5000) if any
  // For example, if you're behind a corporate proxy
  proxy: false
}

// Create conf it it doesn't exist
const data = JSON.stringify(defaults, null, 2)
if (!fs.existsSync(confFile)) fs.writeFileSync(confFile, data)

// Read file
const conf = JSON.parse(fs.readFileSync(confFile))

// Assign defaults and export
module.exports = { ...defaults, ...conf }

@@ -380,16 +380,22 @@
  Create 
+empty 
 conf it 
@@ -415,55 +415,8 @@
 ist%0A
-const data = JSON.stringify(defaults, null, 2)%0A
 if (
@@ -472,12 +472,12 @@
 le, 
-data
+'%7B%7D'
 )%0A%0A/

Create empty conf if it doesn't exist