Skip to content

Commit 477f168

Browse files
author
AJ ONeal
committed
was missing the field 'content', fixed
1 parent d5a3f14 commit 477f168

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

bin/gist.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,54 @@
55

66
var gist = require('../')
77
, fs = require('fs')
8-
, filename = process.argv[2]
8+
, filepath = process.argv[2]
99
, desc = process.argv[3]
1010
;
1111

1212
function usage() {
1313
console.log('Usage: gist </path/to/file>');
1414
}
1515

16-
if (!filename) {
16+
if (!filepath) {
1717
usage();
1818
return;
1919
}
2020

21-
fs.readFile(filename, 'utf8', function (err, data) {
21+
fs.readFile(filepath, 'utf8', function (err, data) {
2222
var meta
23-
, name = filename.replace(/.*\//, '')
23+
, filename = filepath.replace(/.*\//, '')
2424
;
2525

26+
filename = 'index.js';
27+
2628
if (err) {
2729
usage();
2830
return;
2931
}
3032

3133
meta = {
32-
"description": desc
34+
"description": desc || ""
3335
, "public": true
3436
, "files": {}
3537
};
36-
meta.files[name] = data;
38+
meta.files[filename] = { content: data };
3739

3840
gist().create(meta, function (err, resp, json) {
39-
//console.log(JSON.stringify(json, null, ' '));
41+
if (err) {
42+
console.error(err);
43+
return;
44+
}
45+
46+
if (json.errors) {
47+
console.log('[DEBUG]');
48+
console.log(JSON.stringify(meta, null, ' '));
49+
console.log('[GIST ERROR]');
50+
console.log(JSON.stringify(json, null, ' '));
51+
return;
52+
}
53+
4054
console.log('[gist]', json.html_url);
41-
console.log('[raw]', json.files[name].raw_url);
55+
console.log('[raw]', json.files[filename].raw_url);
4256
console.log('[git]', json.git_push_url);
4357
});
4458
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"api",
88
"package.json"
99
],
10-
"version": "1.0.0",
10+
"version": "1.0.1",
1111
"author": "Max Ogden <mogden@gmail.com>",
1212
"repository": {
1313
"type": "git",

0 commit comments

Comments
 (0)