|
@ -22,8 +22,14 @@ cli.add_argument('type', { |
|
|
choices: [ 'good', 'bad' ] |
|
|
choices: [ 'good', 'bad' ] |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
cli.add_argument('spec', { |
|
|
cli.add_argument('-s', '--spec', { |
|
|
help: 'spec file to read' |
|
|
help: 'spec file to read', |
|
|
|
|
|
default: require('path').join(__dirname, '../test/fixtures/commonmark/spec.txt') |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
cli.add_argument('-o', '--output', { |
|
|
|
|
|
help: 'output file, stdout if not set', |
|
|
|
|
|
default: '-' |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
var options = cli.parse_args(); |
|
|
var options = cli.parse_args(); |
|
@ -103,21 +109,26 @@ readFile(options.spec, 'utf8', function (error, input) { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
var out = []; |
|
|
|
|
|
|
|
|
if (!options.type) { |
|
|
if (!options.type) { |
|
|
console.log(util.format('CM spec stat: passed samples - %s, failed samples - %s', good.length, bad.length)); |
|
|
out.push(util.format('CM spec stat: passed samples - %s, failed samples - %s', good.length, bad.length)); |
|
|
} else { |
|
|
} else { |
|
|
var data = options.type === 'good' ? good : bad; |
|
|
var data = options.type === 'good' ? good : bad; |
|
|
|
|
|
|
|
|
data.forEach(function (sample) { |
|
|
data.forEach(function (sample) { |
|
|
console.log(util.format( |
|
|
out.push(util.format( |
|
|
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' + |
|
|
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' + |
|
|
'src line: %s\n\n.\n%s.\n%s.\n', |
|
|
'src line: %s\n\n.\n%s.\n%s.\n', |
|
|
sample.line, sample.md, sample.html)); |
|
|
sample.line, sample.md, sample.html)); |
|
|
if (sample.err) { |
|
|
if (sample.err) { |
|
|
console.log(util.format('error:\n\n%s\n', sample.err)); |
|
|
out.push(util.format('error:\n\n%s\n', sample.err)); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (options.output != '-') fs.writeFileSync(options.output, out.join('\n')); |
|
|
|
|
|
else console.log(out.join('\n')); |
|
|
|
|
|
|
|
|
process.exit(0); |
|
|
process.exit(0); |
|
|
}); |
|
|
}); |
|
|