11#!/usr/bin/env node
22
3- const CommonVocabulary = require ( '.. /common-vocabulary' )
4- const LexiconFactory = require ( '.. /lexicon-factory' )
3+ const CommonVocabulary = require ( './common-vocabulary' )
4+ const LexiconFactory = require ( './lexicon-factory' )
55const meow = require ( 'meow' )
66const path = require ( 'path' )
77
@@ -59,7 +59,7 @@ const options = {
5959 'flags' : {
6060 'output' : {
6161 'alias' : 'o' ,
62- 'default' : path . resolve ( __dirname , '../../ docs/common-vocabulary.md' ) ,
62+ 'default' : path . resolve ( process . cwd ( ) , 'docs/common-vocabulary.md' ) ,
6363 'type' : 'string'
6464 }
6565 }
@@ -69,7 +69,6 @@ const decorator = {
6969 forReports ( cli , commonVocabulary ) {
7070 commonVocabulary . report = ( ) => {
7171 const destination = cli . flags . output || options . flags . output . default
72-
7372 const lexicon = commonVocabulary . toHtml ( )
7473 const lexiconFactory = new LexiconFactory ( )
7574 lexiconFactory . report ( destination , lexicon )
@@ -79,7 +78,15 @@ const decorator = {
7978 forStdout ( cli , commonVocabulary ) {
8079 const method = cli . input . shift ( ) || 'report'
8180 // eslint-disable-next-line no-console
82- console . log ( commonVocabulary [ method ] ( cli . input ) )
81+ const out = commonVocabulary [ method ] ( cli . input )
82+ console . log ( decorator . toMessage ( out ) )
83+ } ,
84+
85+ toMessage ( out ) {
86+ if ( ! out ) {
87+ return 'Nothing found.'
88+ }
89+ return out
8390 }
8491}
8592
0 commit comments