Skip to content
This repository was archived by the owner on Jul 21, 2021. It is now read-only.

add command line script to fetch bug status #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add command link script to repository
emceeaich committed Jul 8, 2016
commit f8eed3fa2bbb22acbba6186a609031a0feb70b0e
38 changes: 38 additions & 0 deletions bin/readable-status.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /usr/bin/env node

var fetch = require('node-fetch');
var readable = require('../index').readable;

// check arguments

if (process.argv.length < 3) {
process.exit(1);
}

var args = process.argv.slice(2);
var bugid = args.shift();

// request bug

fetch('https://bugzilla.mozilla.org/rest/bug/' + bugid).
then(function(res) {
if (res.ok) {
res.json().then(function(json) {
var bug = json.bugs.shift();
var result = readable(bug);
if (result.error) {
console.log(result.error);
} else {
console.log(result);
}
});
} else {
console.log(res.statusText);
process.exit(1);
}
}).
catch(function(error) {
console.log('Failed to reach bugzilla.mozilla.org.');
process.exit(1);
});