@@ -82,53 +82,52 @@ export function useBuiltPackagesVersions(): Promise<void> {
82
82
} ) ;
83
83
}
84
84
85
- export function useSha ( ) {
85
+ export async function useSha ( ) : Promise < void > {
86
86
const argv = getGlobalVariable ( 'argv' ) ;
87
- if ( argv [ 'ng-snapshots' ] || argv [ 'ng-tag' ] ) {
88
- // We need more than the sha here, version is also needed. Examples of latest tags:
89
- // 7.0.0-beta.4+dd2a650
90
- // 6.1.6+4a8d56a
91
- const label = argv [ 'ng-tag' ] ? argv [ 'ng-tag' ] : '' ;
92
- const ngSnapshotVersions = require ( '../ng-snapshot/package.json' ) ;
93
- return updateJsonFile ( 'package.json' , ( json ) => {
94
- // Install over the project with snapshot builds.
95
- function replaceDependencies ( key : string ) {
96
- const missingSnapshots : string [ ] = [ ] ;
97
- Object . keys ( json [ key ] || { } )
98
- . filter ( ( name ) => name . match ( / ^ @ a n g u l a r \/ / ) )
99
- . forEach ( ( name ) => {
100
- const pkgName = name . split ( / \/ / ) [ 1 ] ;
101
- if ( pkgName == 'cli' ) {
102
- return ;
103
- }
104
- if ( label ) {
105
- json [ key ] [ `@angular/${ pkgName } ` ] = `github:angular/${ pkgName } -builds${ label } ` ;
106
- } else {
107
- const replacement = ngSnapshotVersions . dependencies [ `@angular/${ pkgName } ` ] ;
108
- if ( ! replacement ) {
109
- missingSnapshots . push ( `missing @angular/${ pkgName } ` ) ;
110
- }
111
- json [ key ] [ `@angular/${ pkgName } ` ] = replacement ;
87
+ if ( ! argv [ 'ng-snapshots' ] && ! argv [ 'ng-tag' ] ) {
88
+ return ;
89
+ }
90
+
91
+ // We need more than the sha here, version is also needed. Examples of latest tags:
92
+ // 7.0.0-beta.4+dd2a650
93
+ // 6.1.6+4a8d56a
94
+ const label = argv [ 'ng-tag' ] || '' ;
95
+ const ngSnapshotVersions = require ( '../ng-snapshot/package.json' ) ;
96
+
97
+ return updateJsonFile ( 'package.json' , ( json ) => {
98
+ // Install over the project with snapshot builds.
99
+ function replaceDependencies ( key : string ) {
100
+ const missingSnapshots : string [ ] = [ ] ;
101
+ Object . keys ( json [ key ] || { } )
102
+ . filter ( ( name ) => name . startsWith ( '@angular/' ) )
103
+ . forEach ( ( name ) => {
104
+ const pkgName = name . split ( / \/ / ) [ 1 ] ;
105
+ if ( pkgName === 'cli' || pkgName === 'ssr' ) {
106
+ return ;
107
+ }
108
+
109
+ if ( label ) {
110
+ json [ key ] [ `@angular/${ pkgName } ` ] = `github:angular/${ pkgName } -builds${ label } ` ;
111
+ } else {
112
+ const replacement = ngSnapshotVersions . dependencies [ `@angular/${ pkgName } ` ] ;
113
+ if ( ! replacement ) {
114
+ missingSnapshots . push ( `missing @angular/${ pkgName } ` ) ;
112
115
}
113
- } ) ;
114
- if ( missingSnapshots . length > 0 ) {
115
- throw new Error (
116
- 'e2e test with --ng-snapshots requires all angular packages be ' +
117
- 'listed in tests/legacy-cli/e2e/ng-snapshot/package.json.\nErrors:\n' +
118
- missingSnapshots . join ( '\n ' ) ,
119
- ) ;
120
- }
116
+ json [ key ] [ `@angular/${ pkgName } ` ] = replacement ;
117
+ }
118
+ } ) ;
119
+ if ( missingSnapshots . length > 0 ) {
120
+ throw new Error (
121
+ 'e2e test with --ng-snapshots requires all angular packages be ' +
122
+ 'listed in tests/legacy-cli/e2e/ng-snapshot/package.json.\nErrors:\n' +
123
+ missingSnapshots . join ( '\n ' ) ,
124
+ ) ;
121
125
}
122
- try {
123
- replaceDependencies ( 'dependencies' ) ;
124
- replaceDependencies ( 'devDependencies' ) ;
125
- } catch ( e ) {
126
- return Promise . reject ( e ) ;
127
- }
128
- } ) ;
129
- } else {
130
- return Promise . resolve ( ) ;
131
- }
126
+ }
127
+
128
+ replaceDependencies ( 'dependencies' ) ;
129
+ replaceDependencies ( 'devDependencies' ) ;
130
+ } ) ;
132
131
}
133
132
134
133
export function useCIDefaults ( projectName = 'test-project' ) : Promise < void > {
0 commit comments