File tree Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Expand file tree Collapse file tree 3 files changed +32
-5
lines changed Original file line number Diff line number Diff line change 6
6
"scripts" : {
7
7
"build" : " ncc build src/main.ts" ,
8
8
"lint" : " eslint . --ext .ts,.tsx" ,
9
- "format" : " prettier --write **/*.ts" ,
10
- "test" : " mocha -r ts-node/register -t 30s 'setupGcloudSDK/tests/*.test.ts'"
9
+ "format" : " prettier --write **/**/* .ts" ,
10
+ "test" : " mocha -r ts-node/register -t 90s 'setupGcloudSDK/tests/*.test.ts'"
11
11
},
12
12
"repository" : {
13
13
"type" : " git" ,
Original file line number Diff line number Diff line change @@ -145,7 +145,30 @@ export function parseServiceAccountKey(
145
145
if ( ! serviceAccountKey . trim ( ) . startsWith ( '{' ) ) {
146
146
serviceAccount = Buffer . from ( serviceAccountKey , 'base64' ) . toString ( 'utf8' ) ;
147
147
}
148
- return JSON . parse ( serviceAccount ) ;
148
+ try {
149
+ return JSON . parse ( serviceAccount ) ;
150
+ } catch ( error ) {
151
+ const keyFormat = `
152
+ {
153
+ "type": "service_account",
154
+ "project_id": "project-id",
155
+ "private_key_id": "key-id",
156
+ "private_key": "-----BEGIN PRIVATE KEY-----\\nprivate-key\\n-----END PRIVATE KEY-----\\n",
157
+ "client_email": "service-account-email",
158
+ "client_id": "client-id",
159
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
160
+ "token_uri": "https://accounts.google.com/o/oauth2/token",
161
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
162
+ "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-account-email"
163
+ }
164
+ ` ;
165
+ const message =
166
+ 'Error parsing credentials: ' +
167
+ error . message +
168
+ '\nEnsure your credentials are base64 encoded or validate JSON format: ' +
169
+ keyFormat ;
170
+ throw new Error ( message ) ;
171
+ }
149
172
}
150
173
151
174
/**
Original file line number Diff line number Diff line change @@ -39,8 +39,12 @@ describe('#downloadAndExtractTool', function() {
39
39
} ) ;
40
40
41
41
afterEach ( async function ( ) {
42
- await io . rmRF ( toolDir ) ;
43
- await io . rmRF ( tempDir ) ;
42
+ try {
43
+ await io . rmRF ( toolDir ) ;
44
+ await io . rmRF ( tempDir ) ;
45
+ } catch ( err ) {
46
+ console . log ( 'Error occurred during cleanup: ' + err ) ;
47
+ }
44
48
} ) ;
45
49
46
50
it ( 'downloads and extracts linux version' , async function ( ) {
You can’t perform that action at this time.
0 commit comments