1717const debug = require ( 'debug' ) ( 'app preview' )
1818debug ( 'loading' )
1919
20- const { isValidFSM, wskflow, zoomToFitButtons, vizAndfsmViewModes, codeViewMode, handleError } = require ( './composer' ) ,
20+ const { isValidFSM, wskflow, zoomToFitButtons, vizAndfsmViewModes, codeViewMode, handleError, optionsToString } = require ( './composer' ) ,
2121 badges = require ( './badges' ) ,
2222 { readFSMFromDisk, compileToFSM } = require ( './create-from-source' ) ,
2323 messages = require ( './messages' ) ,
@@ -111,14 +111,19 @@ module.exports = (commandTree, prequire) => {
111111 entity . type = 'actions'
112112 }
113113
114- if ( options . alreadyWatching && entity . type === 'custom' ) {
114+ if ( execOptions . alreadyWatching ) {
115115 // in filewatch mode (alreadyWatching), command echo is set to false
116- // calling ui.showCustom as the main repl does not do anything for custom type entity when echo is false
117- ui . showCustom ( entity ) ;
118- }
116+ // calling ui.showCustom as the main repl does not do anything for custom type entity when echo is false
117+ if ( entity . type === 'custom' ) {
118+ ui . showCustom ( entity ) ;
119+ }
120+ else {
121+ ui . showEntity ( entity , { show : 'fsm' } )
122+ }
123+ }
119124 else {
120- resolve ( entity ) ;
121- }
125+ resolve ( entity )
126+ }
122127
123128 }
124129 fsmPromise . then ( formatForUser ( defaultMode ) )
@@ -127,14 +132,13 @@ module.exports = (commandTree, prequire) => {
127132 // start rendering an empty JSON
128133 formatForUser ( defaultMode ) ( { } )
129134
130- } else if ( options . alreadyWatching ) {
135+ } else if ( execOptions . alreadyWatching ) {
131136 // we already have the sidecar open to this file,
132137 // so we can report the error in the sidecar
133138
134139 // createFromSource returns error as either an object that's {fsm:errMsg, code:originalCode}, or just the errMsg string
135140 // here we check the error format and send the correct input to formatForUser/handleError
136141 // in sidecar, error message shows in the fsm (JSON) tab. code tab shows the user's js code (if existed).
137-
138142 if ( err . fsm )
139143 formatForUser ( 'fsm' ) ( err ) ;
140144 else
@@ -176,18 +180,14 @@ module.exports = (commandTree, prequire) => {
176180 delete options . e
177181
178182 debug ( 'environment' , environment )
179- }
180-
181- if ( execOptions . alreadyWatching ) {
182- options . alreadyWatching = execOptions . alreadyWatching ;
183- }
183+ }
184184
185185 render ( input , options , execOptions ) . then ( resolve , reject )
186186
187187 // and set up a file watcher to re-render upon change of the file
188188 if ( ! execOptions || ! execOptions . alreadyWatching ) {
189189 chokidar . watch ( expandHomeDir ( input ) ) . on ( 'change' , path => {
190- repl . pexec ( `preview ${ path } ` , { echo : false , alreadyWatching : true } )
190+ repl . pexec ( `preview ${ path } ${ optionsToString ( options ) } ` , { echo : false , alreadyWatching : true , noHistory : true } )
191191 } )
192192 }
193193 } )
0 commit comments