Browse Source

Simplify specsplit arguments

pull/722/head
Vitaly Puzrin 4 years ago
parent
commit
4594d94512
  1. 4
      Makefile
  2. 4
      package.json
  3. 21
      support/specsplit.js

4
Makefile

@ -50,9 +50,7 @@ benchmark-deps:
npm run benchmark-deps
specsplit:
./support/specsplit.js good ./test/fixtures/commonmark/spec.txt > ./test/fixtures/commonmark/good.txt
./support/specsplit.js bad ./test/fixtures/commonmark/spec.txt > ./test/fixtures/commonmark/bad.txt
./support/specsplit.js ./test/fixtures/commonmark/spec.txt
npm run specsplit
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true

4
package.json

@ -17,7 +17,7 @@
},
"scripts": {
"lint": "eslint .",
"test": "npm run lint && nyc mocha && node support/specsplit.js test/fixtures/commonmark/spec.txt",
"test": "npm run lint && nyc mocha && node support/specsplit.js",
"coverage": "npm run test && nyc report --reporter html",
"report-coveralls": "nyc report --reporter=text-lcov | coveralls",
"doc": "node support/build_doc.js",
@ -26,6 +26,8 @@
"gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git",
"browserify": "rollup -c support/rollup.config.js",
"benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1",
"specsplit": "support/specsplit.js good -o test/fixtures/commonmark/good.txt && support/specsplit.js bad -o test/fixtures/commonmark/bad.txt && support/specsplit.js",
"todo": "grep 'TODO' -n -r ./lib 2>/dev/null",
"prepublishOnly": "npm run gh-demo && npm run gh-doc"
},
"files": [

21
support/specsplit.js

@ -22,8 +22,14 @@ cli.add_argument('type', {
choices: [ 'good', 'bad' ]
});
cli.add_argument('spec', {
help: 'spec file to read'
cli.add_argument('-s', '--spec', {
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();
@ -103,21 +109,26 @@ readFile(options.spec, 'utf8', function (error, input) {
}
});
var out = [];
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 {
var data = options.type === 'good' ? good : bad;
data.forEach(function (sample) {
console.log(util.format(
out.push(util.format(
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' +
'src line: %s\n\n.\n%s.\n%s.\n',
sample.line, sample.md, sample.html));
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);
});

Loading…
Cancel
Save