File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ regex = "0.2.1"
33
33
tempdir = " 0.3.4"
34
34
itertools = " 0.7.4"
35
35
tempfile = " 2.2.0"
36
+ shlex = " 0.1.1"
36
37
37
38
# Watch feature
38
39
notify = { version = " 4.0" , optional = true }
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ extern crate serde;
109
109
extern crate serde_derive;
110
110
#[ macro_use]
111
111
extern crate serde_json;
112
+ extern crate shlex;
112
113
extern crate tempdir;
113
114
extern crate tempfile;
114
115
extern crate toml;
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ use std::path::PathBuf;
20
20
use std:: process:: Command ;
21
21
use serde_json;
22
22
use tempfile;
23
+ use shlex:: Shlex ;
23
24
24
25
use errors:: * ;
25
26
use config:: Config ;
@@ -126,6 +127,22 @@ impl CmdRenderer {
126
127
pub fn new ( name : String , cmd : String ) -> CmdRenderer {
127
128
CmdRenderer { name, cmd }
128
129
}
130
+
131
+ fn compose_command ( & self ) -> Result < Command > {
132
+ let mut words = Shlex :: new ( & self . cmd ) ;
133
+ let executable = match words. next ( ) {
134
+ Some ( e) => e,
135
+ None => bail ! ( "Command string was empty" ) ,
136
+ } ;
137
+
138
+ let mut cmd = Command :: new ( executable) ;
139
+
140
+ for arg in words {
141
+ cmd. arg ( arg) ;
142
+ }
143
+
144
+ Ok ( cmd)
145
+ }
129
146
}
130
147
131
148
impl Renderer for CmdRenderer {
@@ -145,8 +162,9 @@ impl Renderer for CmdRenderer {
145
162
serde_json:: to_writer ( & mut temp, & ctx)
146
163
. chain_err ( || "Unable to serialize the RenderContext" ) ?;
147
164
148
- let status = Command :: new ( & self . cmd )
165
+ let status = self . compose_command ( ) ?
149
166
. stdin ( temp)
167
+ . current_dir ( & ctx. destination )
150
168
. status ( )
151
169
. chain_err ( || "Unable to start the renderer" ) ?;
152
170
You can’t perform that action at this time.
0 commit comments