Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

was missing the field 'content', fixed

  • Loading branch information...
commit 477f168f6eb02ff20d55d48901cf740502d7af29 1 parent d5a3f14
AJ ONeal authored October 26, 2012

Showing 2 changed files with 23 additions and 9 deletions. Show diff stats Hide diff stats

  1. 30  bin/gist.js
  2. 2  package.json
30  bin/gist.js
@@ -5,7 +5,7 @@
5 5
 
6 6
   var gist = require('../')
7 7
     , fs = require('fs')
8  
-    , filename = process.argv[2]
  8
+    , filepath = process.argv[2]
9 9
     , desc = process.argv[3]
10 10
     ;
11 11
 
@@ -13,32 +13,46 @@
13 13
     console.log('Usage: gist </path/to/file>');
14 14
   }
15 15
 
16  
-  if (!filename) {
  16
+  if (!filepath) {
17 17
     usage();
18 18
     return;
19 19
   }
20 20
 
21  
-  fs.readFile(filename, 'utf8', function (err, data) {
  21
+  fs.readFile(filepath, 'utf8', function (err, data) {
22 22
     var meta
23  
-      , name = filename.replace(/.*\//, '')
  23
+      , filename = filepath.replace(/.*\//, '')
24 24
       ;
25 25
 
  26
+    filename = 'index.js';
  27
+
26 28
     if (err) {
27 29
       usage();
28 30
       return;
29 31
     }
30 32
 
31 33
     meta = {
32  
-        "description": desc
  34
+        "description": desc || ""
33 35
       , "public": true
34 36
       , "files": {}
35 37
     };
36  
-    meta.files[name] = data;
  38
+    meta.files[filename] = { content: data };
37 39
 
38 40
     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
+
40 54
       console.log('[gist]', json.html_url);
41  
-      console.log('[raw]', json.files[name].raw_url);
  55
+      console.log('[raw]', json.files[filename].raw_url);
42 56
       console.log('[git]', json.git_push_url);
43 57
     });
44 58
   });
2  package.json
@@ -7,7 +7,7 @@
7 7
     "api",
8 8
     "package.json"
9 9
   ],
10  
-  "version": "1.0.0",
  10
+  "version": "1.0.1",
11 11
   "author": "Max Ogden <mogden@gmail.com>",
12 12
   "repository": {
13 13
     "type": "git",

0 notes on commit 477f168

Please sign in to comment.
Something went wrong with that request. Please try again.