| 
									
										
										
										
											2016-03-12 18:50:43 +00:00
										 |  |  | #!/bin/bash | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cat > test.js << EOF | 
					
						
							|  |  |  | var task = new Task(); | 
					
						
							|  |  |  | task.activate(); | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | task.execute({name: "child.js", source: utf8Decode(File.readFile("child.js"))}).then(function() { | 
					
						
							|  |  |  | 	task.getExports().then(function(exp) { | 
					
						
							|  |  |  | 		return exp.add(1, 1); | 
					
						
							| 
									
										
										
										
											2016-03-12 18:50:43 +00:00
										 |  |  | 	}).then(function(sum) { | 
					
						
							|  |  |  | 		exit(1); | 
					
						
							|  |  |  | 	}).catch(function(error) { | 
					
						
							|  |  |  | 		print("Caught: " + error.message); | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | 		if (error.stack) { | 
					
						
							|  |  |  | 			print("stack: " + error.stack); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-03-12 18:50:43 +00:00
										 |  |  | 		exit(0); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | }).catch(function(e) { | 
					
						
							|  |  |  | 	print("caught", e.message); | 
					
						
							| 
									
										
										
										
											2016-03-12 18:50:43 +00:00
										 |  |  | }); | 
					
						
							|  |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | cat > child.js << EOF | 
					
						
							|  |  |  | exports = { | 
					
						
							|  |  |  | 	add: function(left, right) { | 
					
						
							|  |  |  | 		throw new Error("fail"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2021-01-02 18:10:00 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2016-03-12 18:50:43 +00:00
										 |  |  | EOF | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-13 13:37:58 +00:00
										 |  |  | $TILDEFRIENDS test.js |