@@ -95,6 +95,7 @@ export default class GithubIssuesLabelSync {
9595 this . _labels = [ ] ;
9696 this . _deletedLabels = [ ] ;
9797 this . _createdLabels = [ ] ;
98+ this . _updatedLabels = [ ] ;
9899
99100 this . authenticate ( ) ;
100101 }
@@ -163,6 +164,14 @@ export default class GithubIssuesLabelSync {
163164 return this . _createdLabels ;
164165 }
165166
167+ /**
168+ * Get github API repository updated labels
169+ * @type {Array<GithubIssuesLabelSync.Label> }
170+ */
171+ get updatedLabels ( ) {
172+ return this . _updatedLabels ;
173+ }
174+
166175 /**
167176 * Set github API Client options
168177 * @type {Object } Options we instantiate the github api package with
@@ -232,6 +241,14 @@ export default class GithubIssuesLabelSync {
232241 this . _createdLabels . push ( label ) ;
233242 }
234243
244+ /**
245+ * Push github API repository updated label
246+ * @type {GithubIssuesLabelSync.Label }
247+ */
248+ set updatedLabel ( label ) {
249+ this . _updatedLabels . push ( label ) ;
250+ }
251+
235252 /**
236253 * We only do this once
237254 * @access private
@@ -400,6 +417,58 @@ export default class GithubIssuesLabelSync {
400417 } ) ;
401418 }
402419
420+ /**
421+ * Update github API repository label on remote
422+ * @example
423+ * githubIssuesLabelSync.updateLabel(label).then((response) => {
424+ * console.log(response);
425+ * }).catch((error) => {
426+ * console.log(error.toJSON());
427+ * });
428+ * @async
429+ * @param {GithubIssuesLabelSync.Label } label - The label we want to update
430+ * @param {String } label.name - The label's name
431+ * @param {String } label.color - The label's colour
432+ * @param {String } label.status - Promise status of operation
433+ * @return {Promise<GithubIssuesLabelSync.createdLabels, Error> } Updated label
434+ */
435+ updateLabel ( label ) {
436+ return new Promise ( ( resolve , reject ) => {
437+ return this . github . issues . updateLabel ( {
438+ "user" : this . user ,
439+ "repo" : this . repo ,
440+ "name" : label . name ,
441+ "color" : label . color
442+ } , ( error ) => {
443+ if ( error ) {
444+ reject ( error ) ;
445+ } else {
446+ label . status = 'success' ;
447+ this . updatedLabel = label ;
448+ resolve ( this . updatedLabels ) ;
449+ }
450+ } ) ;
451+ } ) ;
452+ }
453+
454+ /**
455+ * Update github API repository labels on remote
456+ * @example
457+ * githubIssuesLabelSync.updateLabels(labels).then((response) => {
458+ * console.log(response);
459+ * }).catch((error) => {
460+ * console.log(error.toJSON());
461+ * });
462+ * @async
463+ * @param {Array<GithubIssuesLabelSync.Label> } labels - The labels we want to update
464+ * @return {Promise<GithubIssuesLabelSync.createdLabels, Error> } Array of updated labels
465+ */
466+ updateLabels ( labels ) {
467+ return Promise . all ( labels ) . map ( ( label ) => {
468+ return this . updateLabel ( label ) ;
469+ } ) ;
470+ }
471+
403472 /**
404473 * Delete all github API repository labels on remote
405474 * @example
0 commit comments