Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/commands/__test__/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,3 +786,62 @@ it('aborts the release if the package does not pass publint', async () => {
'Must not log a successful release',
).not.toHaveBeenCalledWith('release "v0.1.0" completed!')
})

it('publishes the release if publint reports only warnings', async () => {
api.use(
graphql.query('GetCommitAuthors', () => {
return HttpResponse.json({ data: {} })
}),
githubLatestReleaseHandler,
http.post<never, never, GitHubRelease>(
'https://api.github.com/repos/:owner/:repo/releases',
() => {
return HttpResponse.json(
{
tag_name: 'v1.0.0',
html_url: '/releases/1',
},
{ status: 201 },
)
},
),
)

const repo = await createRepository('publish--lint-warning')
await repo.fs.create({
'package.json': JSON.stringify({
name: 'test',
version: '0.0.0',
main: './index.js',
}),
// ESM syntax in a ".js" file of a CJS package
// makes publint report a "FILE_INVALID_FORMAT" warning.
'index.js': 'export default {}',
})

await repo.fs.exec(`git add . && git commit -m 'feat: new things'`)

const publish = new Publish(
{
profiles: [
{
name: 'latest',
use: 'echo "release script input: $RELEASE_VERSION"',
},
],
},
{
_: [],
profile: 'latest',
},
)

await publish.run()

expect(process.exit).not.toHaveBeenCalledWith(1)
expect(log.warn).toHaveBeenCalledWith(
expect.stringContaining('is written in'),
)
expect(log.error).not.toHaveBeenCalled()
expect(log.info).toHaveBeenCalledWith('release "v0.1.0" completed!')
})
2 changes: 1 addition & 1 deletion src/utils/lint-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function lintPackage(): Promise<void> {
const logLevel = message.type === 'error' ? 'error' : 'warn'
log[logLevel](formatMessage(message, pkg))

if (message.type === 'error' || message.type === 'warning') {
if (message.type === 'error') {
isValid = false
}
}
Expand Down