Skip to content

Commit

Permalink
publishPackageOnNpmCallback() util does not remove a package even if …
Browse files Browse the repository at this point in the history
…npm says it was published.
  • Loading branch information
pomek committed Oct 25, 2024
1 parent 6188a50 commit e152021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
export default async function publishPackageOnNpmCallback( packagePath, taskOptions ) {
const { tools } = await import( '@ckeditor/ckeditor5-dev-utils' );
const { default: fs } = await import( 'fs-extra' );

try {
await tools.shExec( `npm publish --access=public --tag ${ taskOptions.npmTag }`, {
Expand All @@ -22,7 +21,7 @@ export default async function publishPackageOnNpmCallback( packagePath, taskOpti
verbosity: 'error'
} );

await fs.remove( packagePath );
// Do nothing if `npm publish` says "OK". We cannot trust anything npm says.
} catch {
// Do nothing if an error occurs. A parent task will handle it.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ describe( 'publishPackageOnNpmCallback()', () => {
} );
} );

it( 'should remove package directory after publishing on npm', () => {
// See: https://github.com/ckeditor/ckeditor5/issues/17322.
it( 'should not remove package directory after publishing on npm', async () => {
const packagePath = '/workspace/ckeditor5/packages/ckeditor5-foo';

return publishPackageOnNpmCallback( packagePath, { npmTag: 'nightly' } )
.then( () => {
expect( fs.remove ).toHaveBeenCalledTimes( 1 );
expect( fs.remove ).toHaveBeenCalledWith( packagePath );
} );
await publishPackageOnNpmCallback( packagePath, { npmTag: 'nightly' } );

expect( fs.remove ).not.toHaveBeenCalled();
} );

it( 'should not remove a package directory and not throw error when publishing on npm failed with code 409', async () => {
vi.mocked( tools.shExec ).mockRejectedValue( new Error( 'code E409' ) );
// See: https://github.com/ckeditor/ckeditor5/issues/17120
it( 'should not remove a package directory and not throw error when publishing on npm failed', async () => {
vi.mocked( tools.shExec ).mockRejectedValue( new Error( 'I failed because I can' ) );

const packagePath = '/workspace/ckeditor5/packages/ckeditor5-foo';

Expand Down

0 comments on commit e152021

Please sign in to comment.