@@ -15,11 +15,7 @@ describe('authutil tests', () => {
15
15
let dbgSpy : jest . SpyInstance ;
16
16
17
17
beforeAll ( async ( ) => {
18
- const randPath = path . join (
19
- Math . random ( )
20
- . toString ( 36 )
21
- . substring ( 7 )
22
- ) ;
18
+ const randPath = path . join ( Math . random ( ) . toString ( 36 ) . substring ( 7 ) ) ;
23
19
console . log ( '::stop-commands::stoptoken' ) ; // Disable executing of runner commands when running tests in actions
24
20
process . env [ 'GITHUB_ENV' ] = '' ; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
25
21
const tempDir = path . join ( _runnerDir , randPath , 'temp' ) ;
@@ -67,10 +63,10 @@ describe('authutil tests', () => {
67
63
} , 100000 ) ;
68
64
69
65
function readRcFile ( rcFile : string ) {
70
- let rc = { } ;
71
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
66
+ const rc = { } ;
67
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
72
68
for ( const line of contents . split ( os . EOL ) ) {
73
- let parts = line . split ( '=' ) ;
69
+ const parts = line . split ( '=' ) ;
74
70
if ( parts . length == 2 ) {
75
71
rc [ parts [ 0 ] . trim ( ) ] = parts [ 1 ] . trim ( ) ;
76
72
}
@@ -82,8 +78,8 @@ describe('authutil tests', () => {
82
78
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'false' ) ;
83
79
84
80
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
85
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
86
- let rc = readRcFile ( rcFile ) ;
81
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
82
+ const rc = readRcFile ( rcFile ) ;
87
83
expect ( rc [ 'registry' ] ) . toBe ( 'https://registry.npmjs.org/' ) ;
88
84
expect ( rc [ 'always-auth' ] ) . toBe ( 'false' ) ;
89
85
} ) ;
@@ -92,7 +88,7 @@ describe('authutil tests', () => {
92
88
await auth . configAuthentication ( 'https://registry.npmjs.org' , 'false' ) ;
93
89
94
90
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
95
- let rc = readRcFile ( rcFile ) ;
91
+ const rc = readRcFile ( rcFile ) ;
96
92
expect ( rc [ 'registry' ] ) . toBe ( 'https://registry.npmjs.org/' ) ;
97
93
expect ( rc [ 'always-auth' ] ) . toBe ( 'false' ) ;
98
94
} ) ;
@@ -102,7 +98,7 @@ describe('authutil tests', () => {
102
98
await auth . configAuthentication ( 'https://registry.npmjs.org' , 'false' ) ;
103
99
104
100
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
105
- let rc = readRcFile ( rcFile ) ;
101
+ const rc = readRcFile ( rcFile ) ;
106
102
expect ( rc [ '@myscope:registry' ] ) . toBe ( 'https://registry.npmjs.org/' ) ;
107
103
expect ( rc [ 'always-auth' ] ) . toBe ( 'false' ) ;
108
104
} ) ;
@@ -111,24 +107,24 @@ describe('authutil tests', () => {
111
107
await auth . configAuthentication ( 'npm.pkg.github.com' , 'false' ) ;
112
108
113
109
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
114
- let rc = readRcFile ( rcFile ) ;
110
+ const rc = readRcFile ( rcFile ) ;
115
111
expect ( rc [ '@ownername:registry' ] ) . toBe ( 'npm.pkg.github.com/' ) ;
116
112
expect ( rc [ 'always-auth' ] ) . toBe ( 'false' ) ;
117
113
} ) ;
118
114
119
115
it ( 'Sets up npmrc for always-auth true' , async ( ) => {
120
116
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
121
117
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
122
- let rc = readRcFile ( rcFile ) ;
118
+ const rc = readRcFile ( rcFile ) ;
123
119
expect ( rc [ 'registry' ] ) . toBe ( 'https://registry.npmjs.org/' ) ;
124
120
expect ( rc [ 'always-auth' ] ) . toBe ( 'true' ) ;
125
121
} ) ;
126
122
127
- it ( 'It is already set the NODE_AUTH_TOKEN export it ' , async ( ) => {
123
+ it ( 'is already set the NODE_AUTH_TOKEN export it' , async ( ) => {
128
124
process . env . NODE_AUTH_TOKEN = 'foobar' ;
129
125
await auth . configAuthentication ( 'npm.pkg.github.com' , 'false' ) ;
130
126
expect ( fs . statSync ( rcFile ) ) . toBeDefined ( ) ;
131
- let rc = readRcFile ( rcFile ) ;
127
+ const rc = readRcFile ( rcFile ) ;
132
128
expect ( rc [ '@ownername:registry' ] ) . toBe ( 'npm.pkg.github.com/' ) ;
133
129
expect ( rc [ 'always-auth' ] ) . toBe ( 'false' ) ;
134
130
expect ( process . env . NODE_AUTH_TOKEN ) . toEqual ( 'foobar' ) ;
@@ -137,7 +133,7 @@ describe('authutil tests', () => {
137
133
it ( 'configAuthentication should overwrite non-scoped with non-scoped' , async ( ) => {
138
134
fs . writeFileSync ( rcFile , 'registry=NNN' ) ;
139
135
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
140
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
136
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
141
137
expect ( contents ) . toBe (
142
138
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
143
139
) ;
@@ -146,7 +142,7 @@ describe('authutil tests', () => {
146
142
it ( 'configAuthentication should overwrite only non-scoped' , async ( ) => {
147
143
fs . writeFileSync ( rcFile , `registry=NNN${ os . EOL } @myscope:registry=MMM` ) ;
148
144
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
149
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
145
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
150
146
expect ( contents ) . toBe (
151
147
`@myscope:registry=MMM${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
152
148
) ;
@@ -155,7 +151,7 @@ describe('authutil tests', () => {
155
151
it ( 'configAuthentication should add non-scoped to scoped' , async ( ) => {
156
152
fs . writeFileSync ( rcFile , '@myscope:registry=NNN' ) ;
157
153
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
158
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
154
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
159
155
expect ( contents ) . toBe (
160
156
`@myscope:registry=NNN${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
161
157
) ;
@@ -165,7 +161,7 @@ describe('authutil tests', () => {
165
161
process . env [ 'INPUT_SCOPE' ] = 'myscope' ;
166
162
fs . writeFileSync ( rcFile , `@myscope:registry=NNN` ) ;
167
163
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
168
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
164
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
169
165
expect ( contents ) . toBe (
170
166
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
171
167
) ;
@@ -175,7 +171,7 @@ describe('authutil tests', () => {
175
171
process . env [ 'INPUT_SCOPE' ] = 'myscope' ;
176
172
fs . writeFileSync ( rcFile , `registry=NNN${ os . EOL } @myscope:registry=MMM` ) ;
177
173
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
178
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
174
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
179
175
expect ( contents ) . toBe (
180
176
`registry=NNN${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
181
177
) ;
@@ -185,7 +181,7 @@ describe('authutil tests', () => {
185
181
process . env [ 'INPUT_SCOPE' ] = 'myscope' ;
186
182
fs . writeFileSync ( rcFile , `registry=MMM` ) ;
187
183
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
188
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
184
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
189
185
expect ( contents ) . toBe (
190
186
`registry=MMM${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
191
187
) ;
@@ -198,7 +194,7 @@ describe('authutil tests', () => {
198
194
`@otherscope:registry=NNN${ os . EOL } @myscope:registry=MMM`
199
195
) ;
200
196
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
201
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
197
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
202
198
expect ( contents ) . toBe (
203
199
`@otherscope:registry=NNN${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
204
200
) ;
@@ -208,7 +204,7 @@ describe('authutil tests', () => {
208
204
process . env [ 'INPUT_SCOPE' ] = 'myscope' ;
209
205
fs . writeFileSync ( rcFile , `@otherscope:registry=MMM` ) ;
210
206
await auth . configAuthentication ( 'https://registry.npmjs.org/' , 'true' ) ;
211
- let contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
207
+ const contents = fs . readFileSync ( rcFile , { encoding : 'utf8' } ) ;
212
208
expect ( contents ) . toBe (
213
209
`@otherscope:registry=MMM${ os . EOL } //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${ os . EOL } @myscope:registry=https://registry.npmjs.org/${ os . EOL } always-auth=true`
214
210
) ;
0 commit comments