Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit 3845935

Browse files
author
Dan Schulte
committed
Merge branch 'master' into daschult/removepackagelock
2 parents 40b3b19 + c70fd05 commit 3845935

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Diff for: gulpfile.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,28 @@ gulp.task('publish', (cb) => {
229229
let publishedPackages = 0;
230230
let publishedPackagesSkipped = 0;
231231

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+
}
233240

234241
for (let i = 0; i < nodejsReadmeFilePaths.length; ++i) {
235242
const nodejsReadmeFilePath = nodejsReadmeFilePaths[i];
236-
// console.log(`INFO: Processing ${nodejsReadmeFilePath}`);
237-
238243
const nodejsReadmeFileContents = fs.readFileSync(nodejsReadmeFilePath, 'utf8');
239244
const relativeOutputFolderPath = nodejsReadmeFileContents.match(/output\-folder: \$\(node\-sdks\-folder\)\/(lib\/services\/\S+)/)[1];
240245
const packageFolderPath = path.resolve(azureSDKForNodeRepoRoot, relativeOutputFolderPath);
241246
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.`);
243248
errorPackages++;
244249
}
245250
else {
246251
const packageJsonFilePath = `${packageFolderPath}/package.json`;
247252
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.`);
249254
errorPackages++;
250255
}
251256
else {
@@ -275,17 +280,15 @@ gulp.task('publish', (cb) => {
275280
console.log(`Publishing package "${packageName}" with version "${localPackageVersion}"...${whatif ? " (SKIPPED)" : ""}`);
276281
if (!whatif) {
277282
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);
281286
}
282287
execSync(`npm publish --access public`, { cwd: packageFolderPath });
283-
if (npmAuth) {
284-
fs.unlinkSync(npmrcFilePath);
285-
}
286288
publishedPackages++;
287289
}
288290
catch (error) {
291+
console.log(`ERROR: ${JSON.stringify(error)}`);
289292
errorPackages++;
290293
}
291294
} else {

0 commit comments

Comments
 (0)