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

Commit c12b144

Browse files
committed
Fix crash on open. (See #3.)
1 parent 19afe61 commit c12b144

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

bin/gistup

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,12 @@ var argv = optimist.usage("Usage: \033[1mgistup\033[0m [options] -- [file …]"
6767
})
6868
.argv;
6969

70-
var open = process.platform === "linux" ? "xdg-open" : "open";
71-
7270
queue(1)
7371
.defer(getSettings)
7472
.defer(gitInit)
7573
.defer(gitRemoteDoesNotExist)
7674
.defer(gitListUntrackedFiles)
7775
.await(function(error, settings, _, _, files) {
78-
if (!error && settings.open === false) argv.open = false;
7976
unless(error)
8077
.defer(confirmFiles, files)
8178
.defer(gitAdd, files)
@@ -85,7 +82,7 @@ queue(1)
8582
unless(error)
8683
.defer(gitRemoteAdd, id)
8784
.defer(gitPush)
88-
.defer(openBrowser, id)
85+
.defer(openBrowser, argv.open && settings.open, id)
8986
.await(unless);
9087
});
9188
});
@@ -191,8 +188,8 @@ function gitPush(callback) {
191188
});
192189
}
193190

194-
function openBrowser(id, callback) {
195-
if (!argv.open) return void callback(null);
191+
function openBrowser(open, id, callback) {
192+
if (!open) return void callback(null);
196193
child.exec(open + " " + quote.single(argv.open) + id, function(error, stdout, stderr) {
197194
if (!error && stderr) process.stderr.write(stderr); // ignore errors
198195
callback(null);

lib/gistup/get-settings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ var fs = require("fs"),
33
child = require("child_process"),
44
readline = require("readline");
55

6+
var open = process.platform === "linux" ? "xdg-open" : "open";
7+
68
module.exports = function(callback) {
79
var home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
810
settingsPath = path.join(home, ".gistup.json"),
@@ -53,8 +55,7 @@ module.exports = function(callback) {
5355
readin.close();
5456
token = token.trim().toLowerCase();
5557
if (!/^[0-9a-f]{40}$/.test(token)) return void callback(new UserError("The access token \"" + token + "\" is invalid." + os.EOL + os.EOL + "Did you copy and paste the access token correctly? It should be a" + os.EOL + "forty-character hexadecimal string. Please fix and try again."));
56-
settings = {token: token};
57-
if (error) settings.open = false;
58+
settings = {token: token, open: error ? null : open};
5859
fs.writeFile(settingsPath, JSON.stringify(settings, null, 2), {mode: parseInt("0600", 8)}, function(error) {
5960
callback(error, error ? null : settings);
6061
});
@@ -65,6 +66,7 @@ module.exports = function(callback) {
6566
return;
6667
}
6768

69+
if (!("open" in settings)) settings.open = open;
6870
callback(null, settings);
6971
});
7072
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gistup",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Initialize a gist from the command-line.",
55
"keywords": [
66
"gist",

0 commit comments

Comments
 (0)