@@ -75,11 +75,49 @@ for (let arg of process.argv.slice(2)) {
7575 else
7676 switch ( commands [ 0 ] ) {
7777 case "build" :
78+ for ( const { name, oldLength, minLength } of await build ( commands [ 1 ] || "src" , commands [ 2 ] || "dist" ) )
79+ console . log ( `built ${ name } [saved ${ oldLength - minLength } chars]` )
80+
7881 break
79- case "clear" :
82+
83+ case "clear" : {
84+ const config = await getConfig ( )
85+
86+ if ( config . hackmudPath ) {
87+ const target = commands [ 1 ] || "dist"
88+ const user = commands [ 2 ] || config . defaultUser
89+
90+ if ( user ) {
91+ const { pushedRemoved, targetRemoved } = await clear ( target , config . hackmudPath , user )
92+
93+ console . log ( `cleared ${ targetRemoved } file(s) from ${ target } and ${ pushedRemoved } file(s) from ${ user } ` )
94+ } else
95+ console . log ( "set defaultUser in config first" )
96+ } else
97+ console . log ( "set hackmudPath in config first" )
98+
8099 break
81- case "push" :
100+ }
101+
102+ case "push" : {
103+ const config = await getConfig ( )
104+
105+ if ( config . hackmudPath ) {
106+ const target = commands [ 1 ] || "dist"
107+ const user = commands [ 2 ] || config . defaultUser
108+
109+ if ( user ) {
110+ const { pushedCount } = await push ( target , config . hackmudPath , user )
111+
112+ console . log ( `pushed ${ pushedCount } file(s) to ${ user } ` )
113+ } else
114+ console . log ( "set defaultUser in config first" )
115+ } else
116+ console . log ( "set hackmudPath in config first" )
117+
82118 break
119+ }
120+
83121 case "sync" : {
84122 const config = await getConfig ( )
85123
@@ -90,7 +128,6 @@ for (let arg of process.argv.slice(2)) {
90128 const scripts = options . get ( "scripts" ) ?. toString ( ) . split ( "," ) || [ ]
91129
92130 const colours = [ redBright , greenBright , yellowBright , blueBright , magentaBright , cyanBright ]
93-
94131 const userColours = new Map < string , string > ( )
95132
96133 sync ( srcPath , hackmudPath , users , scripts , ( file , { minLength, srcLength, users } ) => {
@@ -102,16 +139,34 @@ for (let arg of process.argv.slice(2)) {
102139 userColours . set ( user , colour = colours [ Math . floor ( Math . random ( ) * colours . length ) ] ( user ) )
103140
104141 return colour
105- } ) . join ( ", " ) } saving ${ bold ( ( srcLength - minLength ) . toString ( ) ) } chars`)
142+ } ) . join ( ", " ) } [saved ${ bold ( ( srcLength - minLength ) . toString ( ) ) } chars] `)
106143 } )
107144 } else
108145 console . log ( "you need to set hackmudPath in config before you can use this command" )
109146
110147 break
111148 }
112149
113- case "watch" :
150+ case "watch" : {
151+ const config = await getConfig ( )
152+
153+ if ( config . hackmudPath ) {
154+ const srcPath = commands [ 1 ] || "src"
155+ const user = commands [ 2 ] || config . defaultUser
156+
157+ if ( user ) {
158+ const { } = await watch ( srcPath , config . hackmudPath , user , ( { minLength, oldLength, name } ) => {
159+ console . log ( `built and pushed ${ name } to ${ user } [saved ${ oldLength - minLength } chars]` )
160+ } )
161+
162+ // console.log(`pushed ${pushedCount} file(s) to ${user}`)
163+ } else
164+ console . log ( "set defaultUser in config first" )
165+ } else
166+ console . log ( "set hackmudPath in config first" )
167+
114168 break
169+ }
115170
116171 case "config" :
117172 switch ( commands [ 1 ] ) {
0 commit comments