@@ -104,25 +104,32 @@ const replaceUsage = (src, { path, commandLoader }) => {
104104 const replacer = assertPlaceholder ( src , path , TAGS . USAGE )
105105 const { usage, name, workspaces } = getCommandByDoc ( path , DOC_EXT , commandLoader )
106106
107- const synopsis = [ '```bash' , usage ]
107+ const synopsis = [ ]
108108
109- const cmdAliases = Object . keys ( aliases ) . reduce ( ( p , c ) => {
110- if ( aliases [ c ] === name ) {
111- p . push ( c )
109+ if ( usage ) {
110+ synopsis . push ( '```bash' , usage )
111+
112+ const cmdAliases = Object . keys ( aliases ) . reduce ( ( p , c ) => {
113+ if ( aliases [ c ] === name ) {
114+ p . push ( c )
115+ }
116+ return p
117+ } , [ ] )
118+
119+ if ( cmdAliases . length === 1 ) {
120+ synopsis . push ( '' , `alias: ${ cmdAliases [ 0 ] } ` )
121+ } else if ( cmdAliases . length > 1 ) {
122+ synopsis . push ( '' , `aliases: ${ cmdAliases . join ( ', ' ) } ` )
112123 }
113- return p
114- } , [ ] )
115124
116- if ( cmdAliases . length === 1 ) {
117- synopsis . push ( '' , `alias: ${ cmdAliases [ 0 ] } ` )
118- } else if ( cmdAliases . length > 1 ) {
119- synopsis . push ( '' , `aliases: ${ cmdAliases . join ( ', ' ) } ` )
125+ synopsis . push ( '```' )
120126 }
121127
122- synopsis . push ( '```' )
123-
124128 if ( ! workspaces ) {
125- synopsis . push ( '' , 'Note: This command is unaware of workspaces.' )
129+ if ( synopsis . length ) {
130+ synopsis . push ( '' )
131+ }
132+ synopsis . push ( 'Note: This command is unaware of workspaces.' )
126133 }
127134
128135 return src . replace ( replacer , synopsis . join ( '\n' ) )
0 commit comments