Skip to content

Commit

Permalink
fix npmrc setup
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Apr 5, 2024
1 parent f765a2f commit 490d9ed
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/components/npm_client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { $ as chainableExeca } from 'execa';
import { writeFile } from 'fs/promises';
import { EOL } from 'os';
import * as path from 'path';

/**
* Type for the response of `npm show <package> --json`
Expand Down Expand Up @@ -32,7 +33,10 @@ export class NpmClient {
*
* By default the client operates in the process cwd
*/
constructor(private readonly npmToken: string | null, cwd?: string) {
constructor(
private readonly npmToken: string | null,
private readonly cwd: string = process.cwd()
) {
this.exec = chainableExeca({ cwd });
this.execWithIO = this.exec({ stdio: 'inherit' });
}
Expand Down Expand Up @@ -84,14 +88,14 @@ export class NpmClient {
configureNpmRc = async () => {
if (this.npmToken) {
await writeFile(
'.npmrc',
path.join(this.cwd, '.npmrc'),
// eslint-disable-next-line spellcheck/spell-checker
`//registry.npmjs.org/:_authToken=${this.npmToken}${EOL}`
);
} else {
// if there's no npm token, assume we are configuring for a local proxy
// copy local config into .npmrc
await writeFile('.npmrc', npmrcLocalTemplate);
await writeFile(path.join(this.cwd, '.npmrc'), npmrcLocalTemplate);
}
};
}
Expand Down

0 comments on commit 490d9ed

Please sign in to comment.