@@ -18,12 +18,13 @@ import { resolve } from "path"
1818import { Arguments , ReactResponse , Registrar , Tab } from "@kui-shell/core"
1919import { setTabReadonly } from "./util"
2020
21- function withFilepath ( cb : ( filepath : string , tab : Tab ) => Promise < ReactResponse [ "react" ] > ) {
21+ function withFilepath ( readonly : boolean , cb : ( filepath : string , tab : Tab ) => Promise < ReactResponse [ "react" ] > ) {
2222 return async ( { tab, argvNoOptions } : Arguments ) => {
23- const filepath = resolve ( argvNoOptions [ 1 ] )
24- setTabReadonly ( { tab } )
23+ if ( readonly ) {
24+ setTabReadonly ( { tab } )
25+ }
2526 return {
26- react : await cb ( filepath , tab ) ,
27+ react : await cb ( resolve ( argvNoOptions [ 1 ] ) , tab ) ,
2728 }
2829 }
2930}
@@ -32,17 +33,19 @@ function withFilepath(cb: (filepath: string, tab: Tab) => Promise<ReactResponse[
3233export default function registerMadwizardCommands ( registrar : Registrar ) {
3334 registrar . listen (
3435 "/guide" ,
35- withFilepath ( ( filepath , tab ) => import ( "./components/PlanAndGuide" ) . then ( ( _ ) => _ . planAndGuide ( filepath , { tab } ) ) ) ,
36+ withFilepath ( true , ( filepath , tab ) =>
37+ import ( "./components/PlanAndGuide" ) . then ( ( _ ) => _ . planAndGuide ( filepath , { tab } ) )
38+ ) ,
3639 { outputOnly : true }
3740 )
3841
3942 registrar . listen (
4043 "/wizard" ,
41- withFilepath ( ( filepath , tab ) => import ( "./components/Guide" ) . then ( ( _ ) => _ . guide ( filepath , { tab } ) ) )
44+ withFilepath ( false , ( filepath , tab ) => import ( "./components/Guide" ) . then ( ( _ ) => _ . guide ( filepath , { tab } ) ) )
4245 )
4346
4447 registrar . listen (
4548 "/plan" ,
46- withFilepath ( ( filepath ) => import ( "./components/Plan" ) . then ( ( _ ) => _ . plan ( filepath ) ) )
49+ withFilepath ( false , ( filepath ) => import ( "./components/Plan" ) . then ( ( _ ) => _ . plan ( filepath ) ) )
4750 )
4851}
0 commit comments