'use strict';

// Load requirements
const path = require('path'),
      fs = require('fs');

// Helper to avoid a lot of directory traversing
global.__base = path.resolve(__dirname + '/../') + '/app/';

module.exports = function() {

  // Define the required files and directories
  let configDir = path.resolve('./config'),
      configFile = path.join(configDir, 'config.json'),
      settingsFile = path.join(configDir, 'settings.json');

  // Create config directory if we don't have one
  if ( ! fs.existsSync(configDir) ) {
    fs.mkdirSync(configDir);
  }

  // Create a base config file if needed
  if ( ! fs.existsSync(configFile) ) {
    fs.writeFileSync(configFile, JSON.stringify({
      setup: true,
      directories: {
        config: configDir,
        settings: configDir
      }
    }, null, 4));
  }

  // Create a base settings file if needed
  if ( ! fs.existsSync(settingsFile) ) {
    fs.writeFileSync(settingsFile,
      JSON.stringify(require(__base + 'libs/setup/data/settings'), null, 4)
    );
  }

};
@@ -83,18 +83,44 @@
 re('fs')
+,%0A      os = require('os')
 ;%0A
-
 %0A// Help
@@ -458,16 +458,70 @@
 s.json')
+,%0A      tasksFile = path.join(configDir, 'tasks.json')
 ;%0A%0A  // 
@@ -981,36 +981,674 @@
 ) %7B%0A
-    fs.writeFileSync(setting
+%0A    let settings = %7B%0A      language: 'en',%0A      platform: %7B%7D,%0A      server: %7B%0A        port: 3001,%0A        address: '0.0.0.0'%0A      %7D,%0A      video: %7B%0A        formats: %5B'mkv', 'mp4', 'avi', 'flv', 'mov', 'wmv'%5D%0A      %7D%0A    %7D;%0A    %0A    // Add os specific settings%0A    settings.platform%5Bos.platform()%5D = %7B%0A      root: '~/',%0A      temp: os.tmpdir() + ( os.platform() === 'win32' ? '%5C%5C' : '/' ),%0A      directories: %7B%0A        show: '/',%0A        movie: '/'%0A      %7D%0A    %7D;%0A%0A    // Write it out%0A    fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 4));%0A  %7D%0A%0A  // Create a base tasks file if needed%0A  if ( ! fs.existsSync(tasksFile) ) %7B%0A    fs.writeFileSync(task
 sFil
@@ -1705,23 +1705,20 @@
 up/data/
-setting
+task
 s'), nul

Update settings and add tasks