Skip to content

Commit e96045b

Browse files
committed
fix(versioner): accept --registry for publish
1 parent 3697854 commit e96045b

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

packages/versioner/src/versioner.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const parserOptions = {
2727
};
2828
const reBreaking = new RegExp(`(${parserOptions.noteKeywords.join(')|(')})`);
2929
const NPM_CLI_SPEC = 'npm@11.5.1';
30+
const DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org/';
3031

3132
type Commit = parser.Commit<string | number | symbol>;
3233

@@ -153,7 +154,14 @@ const publish = async (cwd: string) => {
153154
return;
154155
}
155156

157+
if (typeof argv.registry !== 'undefined' && typeof argv.registry !== 'string') {
158+
throw new TypeError(`--registry must be a string, received: ${typeof argv.registry}`);
159+
}
160+
161+
const registry = argv.registry || DEFAULT_NPM_REGISTRY;
162+
156163
log.info(chalk`\n{cyan Publishing to NPM}`);
164+
log.info(chalk`{grey Registry:} ${registry}`);
157165

158166
const packDir = mkdtempSync(join(tmpdir(), 'versioner-pack-'));
159167
try {
@@ -172,7 +180,16 @@ const publish = async (cwd: string) => {
172180

173181
await execa(
174182
'pnpm',
175-
['dlx', NPM_CLI_SPEC, 'publish', '--no-git-checks', ...provenanceArgs, tarballPath],
183+
[
184+
'dlx',
185+
NPM_CLI_SPEC,
186+
'publish',
187+
'--no-git-checks',
188+
'--registry',
189+
registry,
190+
...provenanceArgs,
191+
tarballPath
192+
],
176193
{ cwd, stdio: 'inherit' }
177194
);
178195
} finally {

0 commit comments

Comments
 (0)