mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	fix Gruntfile.js to work with bew build step
This commit is contained in:
		
							
								
								
									
										50
									
								
								Gruntfile.js
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								Gruntfile.js
									
									
									
									
									
								
							| @@ -2,8 +2,9 @@ | |||||||
|  |  | ||||||
| var fork = require('child_process').fork, | var fork = require('child_process').fork, | ||||||
| 	env = process.env, | 	env = process.env, | ||||||
| 	worker, | 	worker, updateWorker, | ||||||
| 	incomplete = []; | 	incomplete = [], | ||||||
|  | 	running = 0; | ||||||
|  |  | ||||||
|  |  | ||||||
| module.exports = function (grunt) { | module.exports = function (grunt) { | ||||||
| @@ -19,39 +20,44 @@ module.exports = function (grunt) { | |||||||
| 			time = Date.now(); | 			time = Date.now(); | ||||||
| 		 | 		 | ||||||
| 		if (target === 'lessUpdated_Client') { | 		if (target === 'lessUpdated_Client') { | ||||||
| 			fromFile = ['js', 'tpl', 'acpLess']; | 			compiling = 'clientCSS'; | ||||||
| 			compiling = 'clientLess'; |  | ||||||
| 		} else if (target === 'lessUpdated_Admin') { | 		} else if (target === 'lessUpdated_Admin') { | ||||||
| 			fromFile = ['js', 'tpl', 'clientLess']; | 			compiling = 'acpCSS'; | ||||||
| 			compiling = 'acpLess'; |  | ||||||
| 		} else if (target === 'clientUpdated') { | 		} else if (target === 'clientUpdated') { | ||||||
| 			fromFile = ['clientLess', 'acpLess', 'tpl']; |  | ||||||
| 			compiling = 'js'; | 			compiling = 'js'; | ||||||
| 		} else if (target === 'templatesUpdated') { | 		} else if (target === 'templatesUpdated') { | ||||||
| 			fromFile = ['js', 'clientLess', 'acpLess']; |  | ||||||
| 			compiling = 'tpl'; | 			compiling = 'tpl'; | ||||||
| 		} else if (target === 'serverUpdated') { | 		} else if (target === 'serverUpdated') { | ||||||
| 			fromFile = ['clientLess', 'acpLess', 'js', 'tpl']; | 			// Do nothing, just restart | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		fromFile = fromFile.filter(function (ext) { | 		if (incomplete.indexOf(compiling) === -1) { | ||||||
| 			return incomplete.indexOf(ext) === -1; | 			incomplete.push(compiling); | ||||||
| 		}); | 		} | ||||||
|  |  | ||||||
| 		// @psychobunny, re: #5211, instead of this, just call `node app --build js` or `node app --build css,tpl` | 		// @psychobunny, re: #5211, instead of this, just call `node app --build js` or `node app --build css,tpl` | ||||||
| 		updateArgs.push('--from-file=' + fromFile.join(',')); | 		updateArgs.push('--build'); | ||||||
| 		incomplete.push(compiling); | 		updateArgs.push(incomplete.join(',')); | ||||||
|  |  | ||||||
| 		worker.kill(); | 		worker.kill(); | ||||||
| 		worker = fork('app.js', updateArgs, { env: env }); | 		if (updateWorker) { | ||||||
|  | 			updateWorker.kill('SIGKILL'); | ||||||
|  | 		} | ||||||
|  | 		updateWorker = fork('app.js', updateArgs, { env: env }); | ||||||
|  | 		++running; | ||||||
|  | 		updateWorker.on('exit', function () { | ||||||
|  | 			--running; | ||||||
|  | 			if (running === 0) { | ||||||
|  | 				worker = fork('app.js', args, { env: env }); | ||||||
|  | 				worker.on('message', function () { | ||||||
|  | 					if (incomplete.length) { | ||||||
|  | 						incomplete = []; | ||||||
|  |  | ||||||
| 		worker.on('message', function () { | 						if (grunt.option('verbose')) { | ||||||
| 			if (incomplete.length) { | 							grunt.log.writeln('NodeBB restarted in ' + (Date.now() - time) + ' ms'); | ||||||
| 				incomplete = []; | 						} | ||||||
|  | 					} | ||||||
| 				if (grunt.option('verbose')) { | 				}); | ||||||
| 					grunt.log.writeln('NodeBB restarted in ' + (Date.now() - time) + ' ms'); |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user