danger-plugin-lerna
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -23,3 +23,4 @@ "use strict"; | ||
emoji = ':rocket:', | ||
noPublishMessage | ||
noPublishMessage, | ||
formatSuccessMessage | ||
} = {}) => { | ||
@@ -42,2 +43,7 @@ const cwd = process.cwd(); | ||
changed.forEach(pkg => { | ||
if (formatSuccessMessage) { | ||
message(formatSuccessMessage(emoji, pkg)); | ||
return; | ||
} | ||
message(`${emoji} A new version of the \`${pkg.name}\` package will be published.`); | ||
@@ -44,0 +50,0 @@ }); |
{ | ||
"name": "danger-plugin-lerna", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Reports which packages in a lerna mono-repo will be published.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -38,5 +38,20 @@ # danger-plugin-lerna | ||
| name | description | | ||
|-------------------|-------------------------------------------------------------| | ||
| `emoji` | An emoji to prepend to the success message | | ||
| `noPublishMessage`| An optional message to show if there is nothing to publish. | | ||
| name | description | | ||
|-----------------------|-------------------------------------------------------------| | ||
| `emoji` | An emoji to prepend to the success message | | ||
| `noPublishMessage` | A message to show if there is nothing to publish. | | ||
| `formatSuccessMessage`| A function to format the success message. | | ||
**Example:** | ||
```js | ||
import lerna from 'danger-plugin-lerna'; | ||
schedule(lerna({ | ||
emoji: ':thinking:', | ||
noPublishMessage: 'No new package versions will be published', | ||
formatSuccessMessage(emoji, pkg) { | ||
return `${emoji} My custom message about the ${pkg.name} package`; | ||
} | ||
})); | ||
``` |
@@ -13,2 +13,3 @@ import { getPackages } from '@lerna/project'; | ||
noPublishMessage, | ||
formatSuccessMessage, | ||
} = {}) => { | ||
@@ -32,2 +33,7 @@ const cwd = process.cwd(); | ||
changed.forEach((pkg) => { | ||
if (formatSuccessMessage) { | ||
message(formatSuccessMessage(emoji, pkg)); | ||
return; | ||
} | ||
message(`${emoji} A new version of the \`${pkg.name}\` package will be published.`); | ||
@@ -34,0 +40,0 @@ }); |
@@ -125,3 +125,27 @@ import mockFs from 'mock-fs'; | ||
}); | ||
it('adds custom formatting to the success message', async () => { | ||
Object.assign(danger, { | ||
github: { | ||
pr: {}, | ||
}, | ||
}); | ||
collectUpdates.mockReturnValue([ | ||
{ | ||
name: 'package-one', | ||
}, | ||
]); | ||
await lernaPlugin({ | ||
formatSuccessMessage(emoji, pkg) { | ||
return `${emoji} My custom message about the ${pkg.name} package.`; | ||
}, | ||
}); | ||
expect(message).toHaveBeenCalledWith( | ||
':rocket: My custom message about the package-one package.', | ||
); | ||
}); | ||
}); | ||
}); |
12941
293
57