@@ -9,9 +9,9 @@ extension Cmd {
99 /// - Parameter relativePath: Relative path to be converted into full
1010 public func pwd( relativePath path: String ? = nil ) -> EventLoopFuture < String > {
1111 if let path = path {
12- return shell. run ( bash: " TMP_P=$(pwd) && cd \( path. quoteEscape) && pwd && cd \" $TMP_P \" " ) . future. trimMap ( )
12+ return shell. run ( bash: " TMP_P=$(pwd) && cd \( path. quoteEscape) && pwd && cd \" $TMP_P \" " , output : nil ) . future. trimMap ( )
1313 } else {
14- return shell. run ( bash: " pwd " ) . future. trimMap ( )
14+ return shell. run ( bash: " pwd " , output : nil ) . future. trimMap ( )
1515 }
1616 }
1717
@@ -31,13 +31,13 @@ extension Cmd {
3131 /// Return a command path if exists
3232 /// - Parameter command: Command
3333 public func which( _ command: String ) -> EventLoopFuture < String > {
34- return shell. run ( bash: " which \( command) " ) . future. trimMap ( )
34+ return shell. run ( bash: " which \( command) " , output : nil ) . future. trimMap ( )
3535 }
3636
3737 /// Check is folder is empty
3838 /// - Parameter path: Command
3939 public func isEmpty( path: String ) -> EventLoopFuture < Bool > {
40- return shell. run ( bash: " [ '$(ls -A /path/to/directory)' ] && echo 'not empty' || echo 'empty' " ) . future. map { output in
40+ return shell. run ( bash: " [ '$(ls -A /path/to/directory)' ] && echo 'not empty' || echo 'empty' " , output : nil ) . future. map { output in
4141 return output. trimmingCharacters ( in: . whitespacesAndNewlines) == " empty "
4242 }
4343 }
@@ -51,16 +51,19 @@ extension Cmd {
5151 /// Return content of a file as a string
5252 /// - Parameter path: Path to file
5353 public func cat( path: String ) -> EventLoopFuture < String > {
54- return shell. run ( bash: " cat \( path. quoteEscape) " ) . future
54+ return shell. run ( bash: " cat \( path. quoteEscape) " , output : nil ) . future
5555 }
5656
5757 /// List files in a path
5858 /// - Parameter path: Path to file
5959 /// - Parameter flags: Flags
6060 /// - Parameter output: Future
6161 public func ls( path: String , flags: FlagsConvertible ? = nil , output: ( ( String ) -> ( ) ) ? = nil ) -> EventLoopFuture < String > {
62- let flags = flags? . flags ?? " "
63- return shell. run ( bash: " ls \( flags) \( path. quoteEscape) " , output: output) . future
62+ var flags = flags? . flags ?? " "
63+ if !flags. isEmpty {
64+ flags. append ( contentsOf: " " )
65+ }
66+ return shell. run ( bash: " ls \( flags) \( path. quoteEscape) " , output: output) . future
6467 }
6568
6669 /// Remove flags
0 commit comments