File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
2+
3+ const meow = require ( 'meow' ) ;
4+ const cli = meow ( `
5+ Usage
6+ $ create-textlint-rule-example <file-path>
7+
8+ Options
9+ --separator separator between each examples
10+ ` ) ;
211const create = require ( "../lib/create-textlint-rule-example" ) ;
312const concat = require ( 'concat-stream' ) ;
413const fs = require ( 'fs' ) ;
@@ -7,5 +16,7 @@ const input = file && file !== '-'
716 ? fs . createReadStream ( process . argv [ 2 ] )
817 : process . stdin ;
918input . pipe ( concat ( function ( buf ) {
10- console . log ( create ( buf . toString ( 'utf8' ) ) ) ;
19+ console . log ( create ( buf . toString ( 'utf8' ) , {
20+ exampleSeparator : cli . flags . separator
21+ } ) ) ;
1122} ) ) ;
Original file line number Diff line number Diff line change 5151 "babel-preset-latest" : " ^6.24.0" ,
5252 "clone" : " ^2.1.1" ,
5353 "concat-stream" : " ^1.6.0" ,
54- "lodash.uniq" : " ^4.5.0"
54+ "lodash.uniq" : " ^4.5.0" ,
55+ "meow" : " ^3.7.0"
5556 }
5657}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ const defaultOptions = {
1717module . exports = function ( content , options = { } ) {
1818 const prependValidExample = options . prependValidExample || defaultOptions . prependValidExample ;
1919 const prependInValidExample = options . prependInValidExample || defaultOptions . prependInValidExample ;
20- const exampleSeparator = options . exampleSeparator || defaultOptions . exampleSeparator ;
20+ const exampleSeparator = ( options . exampleSeparator || defaultOptions . exampleSeparator ) . replace ( / \\ n / g , "\n" ) ;
2121 const { ruleName, valid, invalid } = getRuleTest ( content ) ;
2222 const plainValid = valid . filter ( text => typeof text === "string" ) ;
2323 const plainInvalid = invalid . filter ( test => {
You can’t perform that action at this time.
0 commit comments