Skip to content

Commit b2f5387

Browse files
author
Nicholas Pape
authored
Add support for using the pnpmfile.js (microsoft#461)
1 parent 3c8a512 commit b2f5387

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎apps/rush-lib/src/RushConstants.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export namespace RushConstants {
6363
*/
6464
export const pnpmShrinkwrapFilename: string = 'shrinkwrap.yaml';
6565

66+
/**
67+
* The filename ("pnpmfile.js") used to add custom configuration to PNPM
68+
*/
69+
export const pnpmFileFilename: string = 'pnpmfile.js';
70+
6671
/**
6772
* The folder name ("node_modules") where NPM installs its packages.
6873
*/

‎apps/rush-lib/src/cli/utilities/InstallManager.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,26 @@ export default class InstallManager {
273273
this._rushConfiguration.tempShrinkwrapFilename);
274274

275275
// Also copy down the committed .npmrc file, if there is one
276-
// "common\.npmrc" --> "common\temp\.npmrc"
276+
// "common\config\rush\.npmrc" --> "common\temp\.npmrc"
277277
const committedNpmrcPath: string = path.join(this._rushConfiguration.commonRushConfigFolder, '.npmrc');
278278
const tempNpmrcPath: string = path.join(this._rushConfiguration.commonTempFolder, '.npmrc');
279+
280+
// ensure that we remove any old one that may be hanging around
281+
fsx.removeSync(tempNpmrcPath);
279282
this.syncFile(committedNpmrcPath, tempNpmrcPath);
280283

284+
// also, copy the pnpmfile.js if it exists
285+
if (this._rushConfiguration.packageManager === 'pnpm') {
286+
const committedPnpmFilePath: string
287+
= path.join(this._rushConfiguration.commonRushConfigFolder, RushConstants.pnpmFileFilename);
288+
const tempPnpmFilePath: string
289+
= path.join(this._rushConfiguration.commonTempFolder, RushConstants.pnpmFileFilename);
290+
291+
// ensure that we remove any old one that may be hanging around
292+
fsx.removeSync(tempPnpmFilePath);
293+
this.syncFile(committedPnpmFilePath, tempPnpmFilePath);
294+
}
295+
281296
const commonPackageJson: IPackageJson = {
282297
dependencies: {},
283298
description: 'Temporary file generated by the Rush tool',

‎apps/rush-lib/src/data/RushConfiguration.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,9 @@ export default class RushConfiguration {
305305
const knownSet: Set<string> = new Set<string>(knownRushConfigFilenames.map(x => x.toUpperCase()));
306306
if (packageManager === 'npm') {
307307
knownSet.add(RushConstants.npmShrinkwrapFilename.toUpperCase());
308-
} else {
308+
} else if (packageManager === 'pnpm') {
309309
knownSet.add(RushConstants.pnpmShrinkwrapFilename.toUpperCase());
310+
knownSet.add(RushConstants.pnpmFileFilename.toUpperCase());
310311
}
311312

312313
// Is the filename something we know? If not, report an error.

0 commit comments

Comments
 (0)