Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

fix #19 support path with dot #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,15 @@ 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) {
const objPath = objectPathCb(path.substring(dir.length));
if (_.has(result, objPath)) {
throw new Error(objPath + ' definition already exists');
}
_.set(result, objPath, path);
_.set(result, supportPathWithDot ? [`${objPath}`] : objPath, path);

return result;
},
Expand All @@ -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');
Expand Down