Skip to content

Commit

Permalink
Merge pull request #1043 from ckeditor/ck/17348
Browse files Browse the repository at this point in the history
Other (release-tools): The `publishPackageOnNpmCallback()` util removes a package directory if npm says it was published. This reverts commit [`a1b37c7`](a1b37c7). Closes ckeditor/ckeditor5#17348.
  • Loading branch information
psmyrek authored Oct 29, 2024
2 parents e9d5757 + 7a6a166 commit 735d7ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
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 @@ -21,7 +22,7 @@ export default async function publishPackageOnNpmCallback( packagePath, taskOpti
verbosity: 'silent'
} );

// Do nothing if `npm publish` says "OK". We cannot trust anything npm says.
await fs.remove( packagePath );
} 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()', () => {
} );
} );

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

await publishPackageOnNpmCallback( packagePath, { npmTag: 'nightly' } );

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

// 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' ) );
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' ) );

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

Expand Down

0 comments on commit 735d7ec

Please sign in to comment.