(options, cwd, steps)
| 145 | } |
| 146 | |
| 147 | function doWatch(options, cwd, steps) { |
| 148 | const { onStart, onBuild, onError } = options; |
| 149 | |
| 150 | return new Promise((resolve, reject) => { |
| 151 | const targetDir = relative(cwd, dirname(options.output)); |
| 152 | stdout(blue(`Watching source, compiling to ${targetDir}:`)); |
| 153 | |
| 154 | const watchers = steps.reduce((acc, options) => { |
| 155 | acc[options.inputOptions.input] = watch( |
| 156 | Object.assign( |
| 157 | { |
| 158 | output: options.outputOptions, |
| 159 | watch: WATCH_OPTS, |
| 160 | }, |
| 161 | options.inputOptions, |
| 162 | ), |
| 163 | ).on('event', e => { |
| 164 | if (e.code === 'START') { |
| 165 | if (typeof onStart === 'function') { |
| 166 | onStart(e); |
| 167 | } |
| 168 | } |
| 169 | if (e.code === 'ERROR') { |
| 170 | logError(e.error); |
| 171 | if (typeof onError === 'function') { |
| 172 | onError(e); |
| 173 | } |
| 174 | } |
| 175 | if (e.code === 'END') { |
| 176 | if (options._sizeInfo) { |
| 177 | options._sizeInfo.then(text => { |
| 178 | stdout(`Wrote ${text.trim()}`); |
| 179 | }); |
| 180 | } |
| 181 | if (typeof onBuild === 'function') { |
| 182 | onBuild(e); |
| 183 | } |
| 184 | } |
| 185 | }); |
| 186 | |
| 187 | return acc; |
| 188 | }, {}); |
| 189 | |
| 190 | resolve({ watchers }); |
| 191 | }); |
| 192 | } |
| 193 | |
| 194 | async function jsOrTs(cwd, filename) { |
| 195 | const extension = (await isFile(resolve(cwd, filename + '.ts'))) |
no test coverage detected
searching dependent graphs…