|
1 |
| -## travis-badge-plugin |
| 1 | +## markdown-magic-branch-badge |
| 2 | + |
| 3 | +A plugin to update your branch badges to point to correct branch status. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +#### Installation : |
| 8 | + |
| 9 | +``` |
| 10 | +npm i markdown-magic markdown-magic-branch-badge --save-dev |
| 11 | +``` |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +#### Usage : |
| 17 | + |
| 18 | +Create a file `update-readme.js` in your project directory. |
| 19 | + |
| 20 | +``` |
| 21 | +const path = require('path'); |
| 22 | +const transformMarkdown = require('markdown-magic'); |
| 23 | +const travisBadgePlugin = require('markdown-magic-branch-badge'); |
| 24 | +
|
| 25 | +const config = { |
| 26 | + transforms: { |
| 27 | + travisBadgePlugin, |
| 28 | + }, |
| 29 | +}; |
| 30 | +
|
| 31 | +function callback() { |
| 32 | + console.log('ReadME generated.'); |
| 33 | +} |
| 34 | +
|
| 35 | +const markdownPath = path.join(__dirname, 'README.md'); |
| 36 | +transformMarkdown(markdownPath, config, callback); |
| 37 | +``` |
| 38 | +Create a file, `example-template` with your template. |
| 39 | + |
| 40 | +``` |
| 41 | +[](https://travis-ci.org/user/repo) |
| 42 | +[](https://some_badge_url.com/user/repo) |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +On your `README.md` add the following lines : |
| 48 | +``` |
| 49 | +<!-- AUTO-GENERATED-CONTENT:START (travisBadgePlugin:src=./example-template) --> |
| 50 | +<!-- AUTO-GENERATED-CONTENT:END --> |
| 51 | +``` |
| 52 | +This indicates the plugin to add the badges between these comments in your readme file. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +**NOTE:** Use `{current_branch}` as placeholders for the plugin to update with branch respective names. |
| 57 | + |
| 58 | +Now, go to the terminal and run: |
| 59 | + |
| 60 | +``` |
| 61 | +node ./update-readme.js |
| 62 | +``` |
| 63 | + |
| 64 | +After running this command, now you should see the updated `README.md` with the badges according to your branch name. |
| 65 | + |
| 66 | +If you have any queries or requests, feel free to open an issue or open a pull request if you want to contribute! |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +##### Usage options: |
| 71 | + |
| 72 | +1. You can use it as a script on your `package.json` and run it manually, or |
| 73 | +2. Use it in a `pre-commit` and `post-checkout` hooks to keep your branches updated with the correct badge URLs. |
0 commit comments