Skip to content

Commit

Permalink
update utils.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Apr 25, 2018
1 parent 85a594e commit 78f30f3
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ const path = require('path');
let controllerDir;
let appName;

function getAppName() {
/**
* returns application name
*
* The name of the application can be different and this function finds it out.
*
* @param {boolean} isInstall
* @returns {string}
*/
function getAppName() {
const parts = __dirname.replace(/\\/g, '/').split('/');
return parts[parts.length - 2].split('.')[0];
}

/**
* @param {boolean} isInstall
* looks for js-controller home folder
*
* @param {boolean} isInstall
* @returns {string}
*/
function getControllerDir(isInstall) {
Expand Down Expand Up @@ -44,8 +54,13 @@ function getControllerDir(isInstall) {
return path.dirname(controllerPath);
}

// Read controller configuration file
function getConfig() {
/**
* reads controller base settings
*
* @alias getConfig
* @returns {object}
*/
function getConfig() {
let configPath;
if (fs.existsSync(
configPath = path.join(controllerDir, 'conf', appName + '.json')
Expand Down

0 comments on commit 78f30f3

Please sign in to comment.