| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | #!/usr/bin/env node
 | 
					
						
							| 
									
										
										
										
											2016-10-04 20:39:20 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * this script is just a temporary solution to deal with the issue of npm outputting the npm | 
					
						
							|  |  |  |  * shrinkwrap file in an unstable manner. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * See: https://github.com/npm/npm/issues/3581
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | const fs = require('fs'); | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | function cleanModule(moduleRecord) { | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  |   // keep `resolve` properties for git dependencies, delete otherwise
 | 
					
						
							|  |  |  |   delete moduleRecord.from; | 
					
						
							|  |  |  |   if (!(moduleRecord.resolved && moduleRecord.resolved.match(/^git(\+[a-z]+)?:\/\//))) { | 
					
						
							|  |  |  |     delete moduleRecord.resolved; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  |   if (moduleRecord.dependencies) { | 
					
						
							|  |  |  |     Object.keys(moduleRecord.dependencies) | 
					
						
							|  |  |  |         .forEach((name) => cleanModule(moduleRecord.dependencies[name])); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-04 20:39:20 -07:00
										 |  |  | // console.log('Reading npm-shrinkwrap.json');
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | const shrinkwrap = require('../../npm-shrinkwrap.json'); | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-04 20:39:20 -07:00
										 |  |  | // console.log('Cleaning shrinkwrap object');
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | cleanModule(shrinkwrap); | 
					
						
							| 
									
										
										
										
											2015-04-15 20:36:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | const cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json'); | 
					
						
							| 
									
										
										
										
											2016-01-02 21:47:09 -08:00
										 |  |  | console.log('writing npm-shrinkwrap.clean.json'); | 
					
						
							| 
									
										
										
										
											2016-10-29 18:40:44 +02:00
										 |  |  | fs.writeFileSync(cleanShrinkwrapPath, JSON.stringify(shrinkwrap, null, 2) + '\n'); |