Comparing version 0.3.0 to 0.3.2
@@ -41,2 +41,5 @@ /* | ||
'reaction': String, | ||
'comment': String, | ||
'best': Boolean, | ||
'bestof': Number, | ||
'repo': String, | ||
@@ -49,2 +52,5 @@ 'user': String | ||
'R': [ '--reaction' ], | ||
'c': [ '--comment' ], | ||
'b': [ '--best' ], | ||
'B': [ '--bestof' ], | ||
'r': [ '--repo' ], | ||
@@ -63,6 +69,4 @@ 'u': [ '--user' ] | ||
if (options.image || options.reaction) { | ||
logger.logTemplate('{{prefix}}Adding comment on {{greenBright "#" options.number}}', { | ||
options: options | ||
}); | ||
if (!options.comment && !options.reaction) { | ||
logger.error('Missing options command.'); | ||
} | ||
@@ -77,2 +81,6 @@ | ||
} | ||
logger.logTemplate('Adding comment on #{{options.number}}', { | ||
options: options | ||
}); | ||
}; | ||
@@ -83,3 +91,4 @@ | ||
options.comment = '![](' + image + ')'; | ||
options.comment = (options.comment) ? options.comment + '<br>' : ''; | ||
options.comment += '![](' + image + ')'; | ||
@@ -96,2 +105,6 @@ this.issue.comment(function(err) { | ||
Gif.prototype.getRandomItem = function (array) { | ||
return array[Math.floor(Math.random() * array.length)]; | ||
}; | ||
Gif.prototype.reaction = function() { | ||
@@ -115,4 +128,15 @@ var instance = this, | ||
random = result[Math.floor(Math.random() * result.length)]; | ||
if (options.best) { | ||
options.image = result[0].images.original.url; | ||
instance.image(options.image); | ||
return; | ||
} | ||
if (options.bestof > 0) { | ||
result = result.slice(0, options.bestof); | ||
} | ||
random = instance.getRandomItem(result); | ||
options.image = random.images.original.url; | ||
instance.image(options.image); | ||
@@ -119,0 +143,0 @@ }); |
{ | ||
"name": "gh-gif", | ||
"description": "NodeGH plugin for commenting on pull requests/issues using GIF reactions", | ||
"version": "0.3.0", | ||
"version": "0.3.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Zeno Rocha", |
@@ -31,2 +31,5 @@ # GH Gif | ||
`-R`, `--reaction` | **Required** | `String` | ||
`-c`, `--comment` | *Optional* | `String` | ||
`-b`, `--best` | *Optional* | `Boolean` | ||
`-B`, `--bestof` | *Optional* | `Number` | ||
`-i`, `--image` | *Optional* | `String` | ||
@@ -44,2 +47,8 @@ `-r`, `--repo` | *Optional* | `String` | ||
You can also use --comment | ||
``` | ||
gh gif 75 --comment "This is cool" --reaction congratulation | ||
``` | ||
* Comment on pull request/issue #75 of a certain repo with a surprised reaction. | ||
@@ -63,2 +72,14 @@ | ||
* Comment on pull request/issue #75 with the best search result | ||
``` | ||
gh gif 75 --reaction happy --best | ||
``` | ||
* Comment on pull request/issue #75 with a random GIF of the first three result items. | ||
``` | ||
gh gif 75 --reaction happy --bestof 3 | ||
``` | ||
## Testing | ||
@@ -65,0 +86,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9755
129
113
0