Skip to content

Commit

Permalink
fall back to plain text if formatter not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed Nov 16, 2015
1 parent cd1b5aa commit 32469da
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ var formatters = {
},
yaml: function (file) {
return yaml_parser.dump(file)
},
txt: function (file) {
return file
}
}

Expand Down Expand Up @@ -135,7 +138,13 @@ helpers.discernParser = function (fileName, opts_) {
*/
helpers.discernFileFormatter = function (fileName) {
var format = helpers.discernFormat(fileName)
return formatters[format]
var formatter = formatters[format]
// If we don't have a parser for this format, notify the user and return as text
if (typeof formatter === 'undefined') {
console.log(chalk.cyan('[indian-ocean] Notice:'), '"' + chalk.bold(format) + '" extension not supported on file: "' + chalk.bold(fileName) + '". Writing out as plain text...')
formatter = formatter['txt']
}
return formatter
}

/**
Expand Down

0 comments on commit 32469da

Please sign in to comment.