fepper-utils
Advanced tools
Comparing version 1.3.1 to 1.3.2
36
index.js
@@ -17,2 +17,4 @@ 'use strict'; | ||
// The difference between conf and pref is that it is recommended to version-control pref.yml, but not conf.yml. | ||
// exports.conf() must always be run before exports.pref(). | ||
// Do not JSDoc. | ||
@@ -95,5 +97,4 @@ exports.conf = () => { | ||
// Turn relative paths into absolute paths. | ||
// Using exports.pathResolve() in case there are double-dots in these confs. | ||
conf.backend_dir = exports.pathResolve(rootDir, conf.backend_dir); | ||
// Turn relative path into absolute path. | ||
// Using exports.pathResolve() in case there are double-dots in this conf. | ||
conf.extend_dir = exports.pathResolve(rootDir, conf.extend_dir); | ||
@@ -142,3 +143,4 @@ | ||
// The difference between conf and pref is that conf values are mandatory. The pref file must still exist even if blank. | ||
// The difference between conf and pref is that it is recommended to version-control pref.yml, but not conf.yml. | ||
// exports.pref() must always be run after exports.conf(). | ||
// Do not JSDoc. | ||
@@ -174,2 +176,17 @@ exports.pref = () => { | ||
// Turn relative path into absolute path. | ||
// Using exports.pathResolve() in case there are double-dots in these prefs or confs. | ||
// It is reasonable to assume that some projects will refer to a backend_dir outside of Fepper with double-dots and | ||
// that the maintainers would want this path to be version-controlled. Therefore, it should be a pref. | ||
if (pref.backend.backend_dir) { | ||
pref.backend.backend_dir = exports.pathResolve(global.rootDir, pref.backend.backend_dir); | ||
// TODO: conf.backend_dir is deprecated and will be removed. | ||
global.conf.backend_dir = pref.backend.backend_dir; | ||
} | ||
else { | ||
// TODO: conf.backend_dir is deprecated and will be removed. | ||
global.conf.backend_dir = exports.pathResolve(global.rootDir, global.conf.backend_dir); | ||
pref.backend.backend_dir = global.conf.backend_dir; | ||
} | ||
exports.extendButNotOverride(pref, defaults); | ||
@@ -409,2 +426,4 @@ | ||
if (backendDir && typeof backendDir === 'string') { | ||
// TODO: conf.backend_dir is deprecated and will be removed. | ||
const backendDirPref = global.pref.backend.backend_dir || global.conf.backend_dir; | ||
const backendDirTrimmed = backendDir.trim(); | ||
@@ -414,7 +433,7 @@ let fullPath; | ||
if (backendDirTrimmed.indexOf(global.conf.backend_dir) === 0) { | ||
if (backendDirTrimmed.indexOf(backendDirPref) === 0) { | ||
fullPath = backendDirTrimmed; | ||
} | ||
else { | ||
fullPath = `${global.conf.backend_dir}/${backendDirTrimmed}`; | ||
fullPath = `${backendDirPref}/${backendDirTrimmed}`; | ||
} | ||
@@ -779,6 +798,9 @@ | ||
exports.webservedDirsCopy = (webservedDirsFull, webservedDirsShort, staticDir) => { | ||
// TODO: conf.backend_dir is deprecated and will be removed. | ||
const backendDirPref = global.pref.backend.backend_dir || global.conf.backend_dir; | ||
for (let i = 0, l = webservedDirsFull.length; i < l; i++) { | ||
try { | ||
fs.copySync( | ||
`${global.conf.backend_dir}/${webservedDirsFull[i]}`, | ||
`${backendDirPref}/${webservedDirsFull[i]}`, | ||
`${staticDir}/${webservedDirsShort[i]}` | ||
@@ -785,0 +807,0 @@ ); |
{ | ||
"name": "fepper-utils", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Fepper utilities", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
40102
668