Skip to content

Commit

Permalink
Allow files to load
Browse files Browse the repository at this point in the history
  • Loading branch information
HexF committed Mar 25, 2020
1 parent cd18a14 commit 50f80d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions aq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let inputFiles: Deno.File[] = []
if(argments["_"].length == 0)
inputFiles = [Deno.stdin]
else
inputFiles = []
inputFiles = argments["_"].map(z => Deno.openSync(z as string, 'r'))

let outputFormat: IFormat = new JSONFormat();
if(argments['json']) outputFormat = new JSONFormat()
Expand All @@ -68,7 +68,7 @@ inputFiles.forEach(async file => {

let format: IFormat;

var detectedFormat = [new JSONFormat(), new TOMLFormat(), new YAMLFormat()].find(f => f.IsOfType(input))
var detectedFormat = [new JSONFormat(), new YAMLFormat(), new TOMLFormat() ].find(f => f.IsOfType(input))
if(detectedFormat)
format = detectedFormat
else{
Expand All @@ -77,14 +77,13 @@ inputFiles.forEach(async file => {
}



if(!format.IsOfType(input)) {
console.error(i18n('formatNoMatch', {format: format.constructor.name}))
Deno.exit(-3)
}

var object:any = format.Unmarshal(input)

var filtered:any = filter(object, userFilter)

var marshaled = outputFormat.Marshal(filtered, argments['color'], argments['compact'])
Expand Down

0 comments on commit 50f80d7

Please sign in to comment.