Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ var config = {
};

var labels = [
{ "name": "bug", "color": "#fc2929" },
{ "name": "duplicate", "color": "#cccccc" }
{ "name": "bug", "color": "#fc2929", "description": "Something isn't working" },
{ "name": "duplicate", "color": "#cccccc", "description": "This issue or pull request already exists" }
];

// remove specified labels from a repo
Expand Down
14 changes: 8 additions & 6 deletions src/lib/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import request from '../lib/request';
* @param {String} server.repo the git repo to manipulate
* @param {String} name the name of the label
* @param {String} color the hexidecimal color of the label
* @param {String} description the description of the label
* @return {Promise}
*/
export function createLabel({api, token, repo}, name, color) {
export function createLabel({api, token, repo}, name, color, description) {
return request({
headers: {'User-Agent': 'request', 'Authorization': `token ${token}`},
headers: {'User-Agent': 'request', 'Authorization': `token ${token}`, 'Accept': 'text/html, application/vnd.github.symmetra-preview+json'},
url: `${api}/${repo}/labels`,
form: JSON.stringify({name, color}),
form: JSON.stringify({name, color, description}),
method: 'POST',
json: true
});
Expand Down Expand Up @@ -72,10 +73,11 @@ export function getLabels({api, token, repo}) {
* @function
* @param {String} name the name of the label
* @param {String} color the hexidecimal color of the label
* @param {String} description the description of the label
* @return {Object} a properly formated label object that can be sent to GitHub
*/
export function formatLabel({name, color}) {
return {name, color: color.replace('#', '')};
export function formatLabel({name, color, description}) {
return {name, description, color: color.replace('#', '')};
}

/**
Expand All @@ -94,7 +96,7 @@ export function createLabels(server, labels) {
return Promise.all(
labels
.map(formatLabel)
.map(({name, color}) => createLabel(server, name, color))
.map(({name, color, description}) => createLabel(server, name, color, description))
);
}

Expand Down
4 changes: 2 additions & 2 deletions test/lib/label.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ chai.use(chaiAsPromised);
describe('Lib: Label', () => {
describe('formatLabel', () => {
it('should return a properly formatted object', () => {
const expected = {name: 'Type: Accepted', color: 'fff' };
const actual = formatLabel({ name: 'Type: Accepted', color: '#fff' });
const expected = {name: 'Type: Accepted', color: 'fff', description: 'This is a description' };
const actual = formatLabel({ name: 'Type: Accepted', color: '#fff', description: 'This is a description' });
return assert.deepEqual(expected, actual);
});
})
Expand Down