Permalink
Browse files

was missing the field 'content', fixed

  • Loading branch information...
1 parent d5a3f14 commit 477f168f6eb02ff20d55d48901cf740502d7af29 @coolaj86 committed Oct 26, 2012
Showing with 23 additions and 9 deletions.
  1. +22 −8 bin/gist.js
  2. +1 −1 package.json
View
30 bin/gist.js
@@ -5,40 +5,54 @@
var gist = require('../')
, fs = require('fs')
- , filename = process.argv[2]
+ , filepath = process.argv[2]
, desc = process.argv[3]
;
function usage() {
console.log('Usage: gist </path/to/file>');
}
- if (!filename) {
+ if (!filepath) {
usage();
return;
}
- fs.readFile(filename, 'utf8', function (err, data) {
+ fs.readFile(filepath, 'utf8', function (err, data) {
var meta
- , name = filename.replace(/.*\//, '')
+ , filename = filepath.replace(/.*\//, '')
;
+ filename = 'index.js';
+
if (err) {
usage();
return;
}
meta = {
- "description": desc
+ "description": desc || ""
, "public": true
, "files": {}
};
- meta.files[name] = data;
+ meta.files[filename] = { content: data };
gist().create(meta, function (err, resp, json) {
- //console.log(JSON.stringify(json, null, ' '));
+ if (err) {
+ console.error(err);
+ return;
+ }
+
+ if (json.errors) {
+ console.log('[DEBUG]');
+ console.log(JSON.stringify(meta, null, ' '));
+ console.log('[GIST ERROR]');
+ console.log(JSON.stringify(json, null, ' '));
+ return;
+ }
+
console.log('[gist]', json.html_url);
- console.log('[raw]', json.files[name].raw_url);
+ console.log('[raw]', json.files[filename].raw_url);
console.log('[git]', json.git_push_url);
});
});
View
2 package.json
@@ -7,7 +7,7 @@
"api",
"package.json"
],
- "version": "1.0.0",
+ "version": "1.0.1",
"author": "Max Ogden <mogden@gmail.com>",
"repository": {
"type": "git",

0 comments on commit 477f168

Please sign in to comment.