@@ -229,23 +229,28 @@ gulp.task('publish', (cb) => {
229
229
let publishedPackages = 0 ;
230
230
let publishedPackagesSkipped = 0 ;
231
231
232
- const npmAuth = process . env [ "npm-auth" ] ;
232
+ const currentDirectoryPath = __dirname ;
233
+
234
+ const npmrcFileName = ".npmrc" ;
235
+ const npmrcRootFilePath = path . join ( currentDirectoryPath , npmrcFileName ) ;
236
+ const npmrcRootFileExists = fs . existsSync ( npmrcRootFilePath ) ;
237
+ if ( npmrcRootFileExists ) {
238
+ console . log ( `Found ".npmrc" auth file at "${ npmrcRootFilePath } ". Using it to authenticate with NPM for publish.` ) ;
239
+ }
233
240
234
241
for ( let i = 0 ; i < nodejsReadmeFilePaths . length ; ++ i ) {
235
242
const nodejsReadmeFilePath = nodejsReadmeFilePaths [ i ] ;
236
- // console.log(`INFO: Processing ${nodejsReadmeFilePath}`);
237
-
238
243
const nodejsReadmeFileContents = fs . readFileSync ( nodejsReadmeFilePath , 'utf8' ) ;
239
244
const relativeOutputFolderPath = nodejsReadmeFileContents . match ( / o u t p u t \- f o l d e r : \$ \( n o d e \- s d k s \- f o l d e r \) \/ ( l i b \/ s e r v i c e s \/ \S + ) / ) [ 1 ] ;
240
245
const packageFolderPath = path . resolve ( azureSDKForNodeRepoRoot , relativeOutputFolderPath ) ;
241
246
if ( ! fs . existsSync ( packageFolderPath ) ) {
242
- console . log ( `ERROR : Package folder ${ packageFolderPath } has not been generated.` ) ;
247
+ console . log ( `WARNING : Package folder ${ packageFolderPath } has not been generated.` ) ;
243
248
errorPackages ++ ;
244
249
}
245
250
else {
246
251
const packageJsonFilePath = `${ packageFolderPath } /package.json` ;
247
252
if ( ! fs . existsSync ( packageJsonFilePath ) ) {
248
- console . log ( `ERROR : Package folder ${ packageFolderPath } is missing its package.json file.` ) ;
253
+ console . log ( `WARNING : Package folder ${ packageFolderPath } is missing its package.json file.` ) ;
249
254
errorPackages ++ ;
250
255
}
251
256
else {
@@ -275,17 +280,15 @@ gulp.task('publish', (cb) => {
275
280
console . log ( `Publishing package "${ packageName } " with version "${ localPackageVersion } "...${ whatif ? " (SKIPPED)" : "" } ` ) ;
276
281
if ( ! whatif ) {
277
282
try {
278
- const npmrcFilePath = path . join ( packageFolderPath , ".npmrc" ) ;
279
- if ( npmAuth ) {
280
- fs . writeFileSync ( npmrcFilePath , npmAuth ) ;
283
+ const npmrcPackageFilePath = path . join ( packageFolderPath , npmrcFileName ) ;
284
+ if ( npmrcRootFileExists ) {
285
+ fs . copyFileSync ( npmrcRootFilePath , npmrcPackageFilePath ) ;
281
286
}
282
287
execSync ( `npm publish --access public` , { cwd : packageFolderPath } ) ;
283
- if ( npmAuth ) {
284
- fs . unlinkSync ( npmrcFilePath ) ;
285
- }
286
288
publishedPackages ++ ;
287
289
}
288
290
catch ( error ) {
291
+ console . log ( `ERROR: ${ JSON . stringify ( error ) } ` ) ;
289
292
errorPackages ++ ;
290
293
}
291
294
} else {
0 commit comments