From 5f713a8a40136367402247e6e711e809330dc70e Mon Sep 17 00:00:00 2001 From: cosrnos Date: Fri, 11 Dec 2015 21:39:43 -0600 Subject: [PATCH] [BUGFIX] Invalid default config path values --- config/defaults.js | 4 ++-- config/loader.js | 26 +++++++++++++++++++++++++- package.json | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/config/defaults.js b/config/defaults.js index 381550d..2965f25 100644 --- a/config/defaults.js +++ b/config/defaults.js @@ -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 diff --git a/config/loader.js b/config/loader.js index c312053..509832d 100644 --- a/config/loader.js +++ b/config/loader.js @@ -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 = { /** @@ -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; } /** @@ -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); } \ No newline at end of file diff --git a/package.json b/package.json index 496bb1f..e918593 100644 --- a/package.json +++ b/package.json @@ -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 (http://cosrnos.com/)", "license": "ISC",