| 
									
										
										
										
											2020-01-07 10:22:35 +08:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2019-11-23 09:27:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const child_process = require('child_process'); | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const files = [ | 
					
						
							| 
									
										
										
										
											2019-12-13 01:02:37 +08:00
										 |  |  |   path.join('src', 'injected', 'zsSelectorEngine.webpack.config.js'), | 
					
						
							| 
									
										
										
										
											2019-11-23 09:27:09 +08:00
										 |  |  |   path.join('src', 'injected', 'injected.webpack.config.js'), | 
					
						
							| 
									
										
										
										
											2020-01-11 08:03:10 +08:00
										 |  |  |   path.join('src', 'web.webpack.config.js'), | 
					
						
							| 
									
										
										
										
											2019-11-23 09:27:09 +08:00
										 |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function runOne(runner, file) { | 
					
						
							|  |  |  |   return runner('npx', ['webpack', '--config', file, ...process.argv.slice(2)], { stdio: 'inherit', shell: true }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const args = process.argv.slice(2); | 
					
						
							|  |  |  | if (args.includes('--watch')) { | 
					
						
							|  |  |  |   const spawns = files.map(file => runOne(child_process.spawn, file)); | 
					
						
							|  |  |  |   process.on('exit', () => spawns.forEach(s => s.kill())); | 
					
						
							|  |  |  | } else { | 
					
						
							|  |  |  |   for (const file of files) { | 
					
						
							|  |  |  |     const out = runOne(child_process.spawnSync, file); | 
					
						
							|  |  |  |     if (out.status) | 
					
						
							|  |  |  |       process.exit(out.status); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |