const path = require('path');
const _ = require('lodash');

function join() {
  // A consistent and normalized version of path.join cross platforms
  return path.normalize(path.join.apply(path, arguments)).replace(/\\/g, '/');
}

let projectRoot;
function setProjectRoot(prjRoot) {
  projectRoot = /\/$/.test(prjRoot) ? prjRoot : prjRoot + '/';
}

function getProjectRoot() {
  if (!projectRoot) {
    setProjectRoot(process.cwd());
  }
  return projectRoot;
}

function map() {
  const args = [getProjectRoot()];
  args.push.apply(args, arguments);
  return join.apply(null, args);
}

function relative(from, to) {
  return path.relative(from, to).replace(/\\/g, '/');
}

// get the module source of 'to' from 'from' file.
// e.g: import to from '../to';
function relativeModuleSource(from, to) {
  const p = join(relative(path.dirname(from), path.dirname(to)), path.basename(to).replace(/\.\w+$/, ''));

  if (!_.startsWith(p, '.')) return './' + p;
  return p;
}

function getFileId(filePath) {
  return filePath.replace(getProjectRoot()).replace(/^\/?/, '');
}

module.exports = {
  join,
  map,
  getFileId,
  setProjectRoot,
  getProjectRoot,
  relative,
  relativeModuleSource,
  getLocalPluginRoot: () => map('tools/plugins'),
};

@@ -23,16 +23,42 @@
 path');%0A
+const os = require('os');%0A
 const _ 
@@ -1085,16 +1085,135 @@
 '');%0A%7D%0A%0A
+const rekitDir = path.join(os.homedir(), './rekit');%0Afunction configFile(file) %7B%0A  return path.join(rekitDir, file);%0A%7D%0A
 module.e
@@ -1299,16 +1299,42 @@
 lative,%0A
+  rekitDir,%0A  configFile,%0A
   relati

Define config dir.