Skip to content
This repository has been 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
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
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(bug.id + ': ' + bug.summary + ': ' + result);
}
});
} else {
console.log(res.statusText);
process.exit(1);
}
}).
catch(function(error) {
console.log('Failed to reach bugzilla.mozilla.org.');
process.exit(1);
});

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"demo": "node test/fetch.js",
"bundle-demo": "browserify test/fetch.js -o bugzilla-readable-status-browser-demo.js"
},
"bin": {
"readable-status": "bin/readable-status.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/emceeaich/bugzilla-readable-status.git"
Expand All @@ -36,7 +39,8 @@
"test": "test"
},
"dependencies": {
"browserify": "^13.0.1",
"minifyify": "^7.3.3",
"browserify": "^13.0.1"
"node-fetch": "^1.5.2"
}
}