From 9a55cfb54401c04a4188c106bd550c0e43680605 Mon Sep 17 00:00:00 2001 From: marc hurabielle Date: Thu, 22 Aug 2019 13:29:41 +0900 Subject: [PATCH] fix #19 support path with dot --- lib/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/index.js b/lib/index.js index 1eb2240..bfb9972 100644 --- a/lib/index.js +++ b/lib/index.js @@ -450,7 +450,7 @@ function filenameToPath(filename) { return '/' + filename.replace(/@/g, '/'); } -function globObject(dir, pattern, objectPathCb) { +function globObject(dir, pattern, objectPathCb, supportPathWithDot = false) { return _.reduce( glob(Path.join(dir, pattern)), function(result, path) { @@ -458,7 +458,7 @@ function globObject(dir, pattern, objectPathCb) { if (_.has(result, objPath)) { throw new Error(objPath + ' definition already exists'); } - _.set(result, objPath, path); + _.set(result, supportPathWithDot ? [`${objPath}`] : objPath, path); return result; }, @@ -467,11 +467,11 @@ function globObject(dir, pattern, objectPathCb) { } function globYamlObject(dir, objectPathCb) { - return _.mapValues(globObject(dir, anyYaml, objectPathCb), readYaml); + return _.mapValues(globObject(dir, anyYaml, objectPathCb, true), readYaml); } function updateGlobObject(dir, object) { - const knownKeys = globObject(dir, anyYaml, baseName); + const knownKeys = globObject(dir, anyYaml, baseName, true); _.each(object, function(value, key) { let filename = Path.join(dir, key + '.yaml');