| 16 | } |
| 17 | |
| 18 | run() { |
| 19 | if (!this.fn) throw new Error('Function is not set') |
| 20 | |
| 21 | // we wrap that function to track time and status |
| 22 | // and disable it in dry run mode |
| 23 | this.args = Array.prototype.slice.call(arguments) |
| 24 | this.startTime = +Date.now() |
| 25 | |
| 26 | if (store.dryRun) { |
| 27 | this.setStatus('success') |
| 28 | // should we add Proxy and dry run resolver here? |
| 29 | return Promise.resolve(true) |
| 30 | } |
| 31 | |
| 32 | let result |
| 33 | try { |
| 34 | result = this.fn.apply(this.helper, this.args) |
| 35 | this.setStatus('success') |
| 36 | this.endTime = +Date.now() |
| 37 | } catch (err) { |
| 38 | this.endTime = +Date.now() |
| 39 | this.setStatus('failed') |
| 40 | throw err |
| 41 | } |
| 42 | return result |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | export default FuncStep |