Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf089d9d

Browse files
authored
fix(README): correct docs on authentication (semantic-release#413)
1 parentd47164d commitf089d9d

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
| Step| Description|
1010
|--------------------|-------------|
11-
|`verifyConditions`| Verify the presence of the`NPM_TOKEN` environment variable,createorupdate the`.npmrc` file with the tokenand verify thetoken is valid.|
11+
|`verifyConditions`| Verify the presence of the`NPM_TOKEN` environment variable, oran`.npmrc` file,and verify theauthentication method is valid.|
1212
|`prepare`| Update the`package.json` version and[create](https://docs.npmjs.com/cli/pack) the npm package tarball.|
1313
|`addChannel`|[Add a release to a dist-tag](https://docs.npmjs.com/cli/dist-tag).|
1414
|`publish`|[Publish the npm package](https://docs.npmjs.com/cli/publish) to the registry.|
@@ -41,7 +41,9 @@ The npm authentication configuration is **required** and can be set via [environ
4141

4242
Both the[token](https://docs.npmjs.com/getting-started/working_with_tokens) and the legacy (`username`,`password` and`email`) authentication are supported. It is recommended to use the[token](https://docs.npmjs.com/getting-started/working_with_tokens) authentication. The legacy authentication is supported as the alternative npm registries[Artifactory](https://www.jfrog.com/open-source/#os-arti) and[npm-registry-couchapp](https://github.com/npm/npm-registry-couchapp) only supports that form of authentication.
4343

44-
**Note**: Only the`auth-only` [level of npm two-factor authentication](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) is supported,**semantic-release** will not work with the default`auth-and-writes` level.
44+
**Notes**:
45+
- Only the`auth-only` [level of npm two-factor authentication](https://docs.npmjs.com/getting-started/using-two-factor-authentication#levels-of-authentication) is supported,**semantic-release** will not work with the default`auth-and-writes` level.
46+
- The presence of an`.npmrc` file will override any specified environment variables.
4547

4648
###Environment variables
4749

‎test/set-npmrc-auth.test.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,30 @@ test.serial('Throw error if "NPM_EMAIL" is missing', async (t) => {
212212
t.is(error.message,'No npm token specified.');
213213
t.is(error.code,'ENONPMTOKEN');
214214
});
215+
216+
test.serial('Prefer .npmrc over environment variables',async(t)=>{
217+
process.env.HOME=tempy.directory();
218+
constcwd=tempy.directory();
219+
process.chdir(cwd);
220+
constnpmrc=tempy.file({name:'.npmrc'});
221+
// Specify an NPM token environment variable
222+
constenv={NPM_TOKEN:'env_npm_token'};
223+
224+
awaitappendFile(path.resolve(cwd,'.npmrc'),'//registry.npmjs.org/:_authToken=npmrc_npm_token');
225+
226+
awaitrequire('../lib/set-npmrc-auth')(npmrc,'http://registry.npmjs.org',{cwd, env,logger:t.context.logger});
227+
228+
t.is(
229+
(awaitreadFile(npmrc)).toString(),
230+
// Assert did not write the token from environment variable
231+
`//registry.npmjs.org/:_authToken=npmrc_npm_token`
232+
);
233+
234+
// Assert reads from config
235+
t.deepEqual(t.context.log.args[1],['Reading npm config from %s',path.resolve(cwd,'.npmrc')]);
236+
237+
// Assert does not write NPM_TOKEN
238+
for(constlogoft.context.log.args){
239+
t.false(log.includes('Wrote NPM_TOKEN'));
240+
}
241+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp