|
|
|
@@ -53,11 +53,20 @@ function run (/*args*/) { |
|
|
|
} |
|
|
|
|
|
|
|
function readView (cb) { |
|
|
|
var view = isStdin(viewArg) ? process.openStdin() : fs.createReadStream(viewArg); |
|
|
|
|
|
|
|
streamToStr(view, function onDone (str) { |
|
|
|
cb(parseView(str)); |
|
|
|
}); |
|
|
|
let view; |
|
|
|
if (isJson(viewArg)) { |
|
|
|
view = require(path.join(process.cwd(),viewArg)); |
|
|
|
cb(view); |
|
|
|
} else { |
|
|
|
if (isStdin(viewArg)) { |
|
|
|
view = process.openStdin(); |
|
|
|
} else { |
|
|
|
view = fs.createReadStream(viewArg); |
|
|
|
} |
|
|
|
streamToStr(view, function onDone (str) { |
|
|
|
cb(parseView(str)); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function parseView (str) { |
|
|
|
@@ -121,6 +130,10 @@ function isStdin (view) { |
|
|
|
return view === '-'; |
|
|
|
} |
|
|
|
|
|
|
|
function isJson (view) { |
|
|
|
return path.parse(view).ext === '.js'; |
|
|
|
} |
|
|
|
|
|
|
|
function wasNotFound (err) { |
|
|
|
return err.code && err.code === 'ENOENT'; |
|
|
|
} |
|
|
|
|