Skip to content

Commit

Permalink
[BUGFIX] Invalid default config path values
Browse files Browse the repository at this point in the history
  • Loading branch information
cosrnos committed Dec 12, 2015
1 parent be7a662 commit 5f713a8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module.exports = {
MAIN_PACKAGE: 'main',

// Build
TEMP_FOLDER: '_build',
TEMP_FOLDER: '/_build',

// Dist
BUILD_TARGET: 'dist',
BUILD_TARGET: '/dist',
SCRIPT_PATH: '',

// Serve
Expand Down
26 changes: 25 additions & 1 deletion config/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const Utils = require('../packages/pacmod-utils/lib/index.js');
// Fixtures
const default_config_values = require('./defaults.js');

const folder_config_keys = ['BUILD_TARGET', 'TEMP_FOLDER', 'SCRIPT_PATH'];

// Public API
module.exports = {
/**
Expand Down Expand Up @@ -145,9 +147,21 @@ function load_pacmod_config(path) {
* @param raw_data
*/
function normalize_pacmod_config_data(raw_data) {
return _.mapKeys(raw_data, (value, key)=> {
let config_data = _.mapKeys(raw_data, (value, key)=> {
return key.toUpperCase();
});

config_data = _.mapValues(raw_data, (value, key) => {
if (_.contains(folder_config_keys, key)) {
if (!is_path_char(value.charAt(0))) {
value = '/' + value;
}
}

return value;
});

return config_data;
}

/**
Expand Down Expand Up @@ -176,4 +190,14 @@ function read_file(path) {
var data = fs.readFileSync(path, 'utf8');
resolve(data);
});
}

/**
* Determines whether the given character is valid at the beginning of a relative path
* @param char
* @returns {boolean}
*/
function is_path_char(char) {
let path_chars = ['.', '/'];
return _.contains(path_chars, char);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pacmod-cli",
"version": "0.4.0",
"version": "0.4.1",
"description": "A package module development environment tool",
"author": "Alex Roth <[email protected]> (http://cosrnos.com/)",
"license": "ISC",
Expand Down

0 comments on commit 5f713a8

Please sign in to comment.