Support alternatives in tips.

This commit is contained in:
Hemanth.HM 2015-07-17 13:01:25 +05:30
parent a082bb79d2
commit 55778710ea
4 changed files with 18 additions and 6 deletions

View File

@ -7,13 +7,18 @@ function escapeStr(str) {
var render = function(data) {
var data = data.data;
return [
var tips = [
'## ' + data.title,
'```sh',
data.tip,
'```',
'\n'
].join('\n');
];
Array.isArray(data.alternatives) && tips.push(['__Alternatives:__']) &&
data.alternatives.map(function(alternative){
tips = tips.concat(['```sh',alternative,'```','\n'])
});
return tips.join('\n');
};
module.exports = render;

View File

@ -98,6 +98,12 @@ git remote set-url origin <URL>
git remote
```
__Alternatives:__
```sh
git remote show
```
## Get list of all local and remote branches
```sh
git branch -a

View File

@ -2,17 +2,18 @@
* [Fork](https://github.com/git-tips/tips/network) the repo.
* Install the deps:
* Install the deps:
```sh
$ cd tips && npm install
```
* Edit [tips.json](./tips.json) to add your tip in the below format:
```js
{
"title": <your_tip_title>,
"tip": <your_tip>
"tip": <your_tip>,
"alternatives": [Optional list of alternatives]
}
```

View File

@ -54,7 +54,7 @@
{
"title": "Get list of all remote references",
"tip": "git remote",
"alternatives": "git remote show"
"alternatives": ["git remote show"]
},
{
"title": "Get list of all local and remote branches",