Skip to content

Commit

Permalink
[cli] resolve template includes to current directory too
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Jan 3, 2018
1 parent c030abf commit b38f731
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Deprecated `Configuration.extract_usage` in favor of `Service.get_usage` [PR #531](https://github.com/3scale/apicast/pull/531)
- Extract Test::APIcast to own package on CPAN [PR #528](https://github.com/3scale/apicast/pull/528)
- Load policies by the APIcast loader instead of changing load path [PR #532](https://github.com/3scale/apicast/pull/532), [PR #536](https://github.com/3scale/apicast/pull/536)
- Load policies by the APIcast loader instead of changing load path [PR #532](https://github.com/3scale/apicast/pull/532)
- Add `src` directory to the Lua load path when using CLI [PR #533](https://github.com/3scale/apicast/pull/533)

## [3.2.0-alpha2] - 2017-11-30
Expand Down
15 changes: 11 additions & 4 deletions gateway/src/apicast/cli/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local setmetatable = setmetatable
local insert = table.insert
local assert = assert
local pairs = pairs
local ipairs = ipairs
local sub = string.sub
local len = string.len
local pack = table.pack
Expand Down Expand Up @@ -71,11 +72,17 @@ function _M:interpret(str)

filter_set:add_filter('filesystem', function(pattern)
local files = {}
local included = {}

for filename, dir in pl.dir.dirtree(self.root) do
local file = pl.path.relpath(filename, self.root)
if pl.dir.fnmatch(file, pattern) and not dir then
insert(files, file)
for _, root in ipairs({ self.root, pl.path.currentdir() }) do
for filename, dir in pl.dir.dirtree(root) do
local file = pl.path.relpath(filename, root)

if pl.dir.fnmatch(file, pattern) and not dir and not included[filename] and not included[file] then
insert(files, filename)
included[filename] = true
included[file] = true
end
end
end

Expand Down

0 comments on commit b38f731

Please sign in to comment.