@@ -18,7 +18,8 @@ import {
1818 IPackageJson ,
1919 MapExtensions ,
2020 FileSystem ,
21- FileConstants
21+ FileConstants ,
22+ Sort
2223} from '@microsoft/node-core-library' ;
2324
2425import { ApprovedPackagesChecker } from '../logic/ApprovedPackagesChecker' ;
@@ -449,9 +450,7 @@ export class InstallManager {
449450 // To make the common/package.json file more readable, sort alphabetically
450451 // according to rushProject.tempProjectName instead of packageName.
451452 const sortedRushProjects : RushConfigurationProject [ ] = this . _rushConfiguration . projects . slice ( 0 ) ;
452- sortedRushProjects . sort (
453- ( a : RushConfigurationProject , b : RushConfigurationProject ) => a . tempProjectName . localeCompare ( b . tempProjectName )
454- ) ;
453+ Sort . sortBy ( sortedRushProjects , x => x . tempProjectName ) ;
455454
456455 for ( const rushProject of sortedRushProjects ) {
457456 const packageJson : PackageJsonEditor = rushProject . packageJsonEditor ;
@@ -480,7 +479,7 @@ export class InstallManager {
480479 // (A given packageName will never appear more than once in this list.)
481480 for ( const dependency of packageJson . dependencyList ) {
482481
483- // If there are any optional dependencies, copy them directly into the optionalDependencies field.
482+ // If there are any optional dependencies, copy directly into the optionalDependencies field.
484483 if ( dependency . dependencyType === DependencyType . Optional ) {
485484 if ( ! tempPackageJson . optionalDependencies ) {
486485 tempPackageJson . optionalDependencies = { } ;
@@ -497,12 +496,9 @@ export class InstallManager {
497496 // want right now for development, not the range that you support for consumers).
498497 tempDependencies . set ( dependency . name , dependency . version ) ;
499498 }
500- const sortedTempDependencyNames : string [ ] = [ ... tempDependencies . keys ( ) ] ;
501- sortedTempDependencyNames . sort ( ) ; // alphabetize them to minimize churn in the tarball
502-
503- for ( const packageName of sortedTempDependencyNames ) {
504- const packageVersion : string = tempDependencies . get ( packageName ) ! ;
499+ Sort . sortMapKeys ( tempDependencies ) ;
505500
501+ for ( const [ packageName , packageVersion ] of tempDependencies . entries ( ) ) {
506502 // Is there a locally built Rush project that could satisfy this dependency?
507503 // If so, then we will symlink to the project folder rather than to common/temp/node_modules.
508504 // In this case, we don't want "npm install" to process this package, but we do need
0 commit comments