aboutsummaryrefslogtreecommitdiff
path: root/files.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-24 17:36:45 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-24 17:36:50 -0700
commitd7e297844c88022cf10ebeb14759a8df7dd539c4 (patch)
treef6ff3310c6708ef351cea0efcd1791a2eb41a502 /files.moon
parentf7a9d1fc6b2ccd95f2f8df49f99073a6d2be9bb8 (diff)
Fixed stdin handling.
Diffstat (limited to 'files.moon')
-rw-r--r--files.moon11
1 files changed, 8 insertions, 3 deletions
diff --git a/files.moon b/files.moon
index ceb24e8..1a9c50a 100644
--- a/files.moon
+++ b/files.moon
@@ -17,6 +17,7 @@ _BROWSE_CACHE = {}
-- Create a fake file and put it in the cache
Files.spoof = (filename, contents)->
+ print("SPOOFING #{filename}")
_SPOOFED_FILES[filename] = contents
return contents
@@ -46,6 +47,7 @@ sanitize = (path)->
Files.exists = (path)->
return true if _SPOOFED_FILES[path]
+ return true if path == 'stdin'
return true if run_cmd("ls #{sanitize(path)}")
for nomsupath in package.nomsupath\gmatch("[^;]+")
return true if run_cmd("ls #{nomsupath}/#{sanitize(path)}")
@@ -74,7 +76,7 @@ if ok
export browse
browse = (filename)->
unless _BROWSE_CACHE[filename]
- _BROWSE_CACHE[filename] = if _SPOOFED_FILES[filename]
+ _BROWSE_CACHE[filename] = if _SPOOFED_FILES[filename] or filename == 'stdin'
{filename}
else
file_type, err = lfs.attributes(filename, 'mode')
@@ -102,8 +104,11 @@ Files.walk = (path, flush_cache=false)->
export _BROWSE_CACHE
_BROWSE_CACHE = {}
local files
- for nomsupath in package.nomsupath\gmatch("[^;]+")
- if files = browse(nomsupath.."/"..path) then break
+ if path == 'stdin'
+ files = {path}
+ else
+ for nomsupath in package.nomsupath\gmatch("[^;]+")
+ if files = browse(nomsupath.."/"..path) then break
iter = (files, i)->
return unless files
i += 1