(cmd, msg)
| 134 | } |
| 135 | |
| 136 | function run(cmd, msg) { |
| 137 | // All calls are actually synchronous but eventually some task |
| 138 | // will need async stuff, so keep them promises |
| 139 | return new Promise(function(resolve, reject) { |
| 140 | if (msg) { |
| 141 | status(msg); |
| 142 | } |
| 143 | |
| 144 | if (config.dryRun) { |
| 145 | return resolve(); |
| 146 | } |
| 147 | |
| 148 | var exec = shell.exec(cmd); |
| 149 | var success = exec.code === 0; |
| 150 | |
| 151 | if (success) { |
| 152 | resolve(exec.output); |
| 153 | } else { |
| 154 | var errMsg = 'Error executing: `' + cmd + '`\nOutput:\n' + exec.output; |
| 155 | var err = new Error(errMsg); |
| 156 | reject(err); |
| 157 | } |
| 158 | }); |
| 159 | } |
| 160 | |
| 161 | // Task functions |
| 162 | // All functions should return promise |
no test coverage detected