Skip to content

Commit e24f4b9

Browse files
committed
cleaning
1 parent 7113e56 commit e24f4b9

File tree

3 files changed

+34
-60
lines changed

3 files changed

+34
-60
lines changed

packages/acceptance-tests/pkg-tests-specs/sources/commands/publish.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {httpUtils} from '@yarnpkg/core';
2+
import {npath, xfs} from '@yarnpkg/fslib';
3+
14
export {};
25

36
const {
@@ -68,4 +71,23 @@ describe(`publish`, () => {
6871
},
6972
})).resolves.toBeTruthy();
7073
}));
74+
75+
test(`should publish package with readme content`, makeTemporaryEnv({
76+
name: `otp-required`,
77+
version: `1.0.0`,
78+
}, async ({path, run, source}) => {
79+
const spy = jest.spyOn(httpUtils, `put`);
80+
await run(`install`);
81+
82+
const readmePath = npath.toPortablePath(`${path}/README.md`);
83+
await xfs.writeFilePromise(readmePath, `# title\n`);
84+
85+
const res = await run(`npm`, `publish`, `--otp`, validLogins.otpUser.npmOtpToken, {
86+
env: {
87+
YARN_NPM_AUTH_TOKEN: validLogins.otpUser.npmAuthToken,
88+
},
89+
});
90+
91+
expect(spy).toHaveBeenCalledWith({});
92+
}));
7193
});

packages/plugin-npm/sources/npmPublishUtils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ export async function getGitHead(workingDir: PortablePath) {
8787

8888
export function getPublishAccess(workspace: Workspace, ident: Ident, access?: string): string {
8989
const configuration = workspace.project.configuration;
90+
if (typeof access === `string`)
91+
return access;
9092

91-
if (typeof access === `undefined`) {
92-
if (workspace.manifest.publishConfig && typeof workspace.manifest.publishConfig.access === `string`) {
93-
access = workspace.manifest.publishConfig.access;
94-
} else if (configuration.get(`npmPublishAccess`) !== null) {
95-
access = configuration.get(`npmPublishAccess`)!;
96-
} else if (ident.scope) {
97-
access = `restricted`;
98-
} else {
99-
access = `public`;
100-
}
101-
}
102-
return access;
93+
if (workspace.manifest.publishConfig && typeof workspace.manifest.publishConfig.access === `string`)
94+
return workspace.manifest.publishConfig.access;
95+
96+
if (configuration.get(`npmPublishAccess`) !== null)
97+
return configuration.get(`npmPublishAccess`)!;
98+
99+
if (ident.scope)
100+
access = `restricted`;
101+
102+
return `public`;
103103
}
104104

105105
export async function getReadmeContent(workspace: Workspace): Promise<string> {

packages/plugin-npm/tests/npmPublishUtils.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)