Skip to content

Commit

Permalink
Merge pull request dthree#92 from addaleax/master
Browse files Browse the repository at this point in the history
use the `username` module’s Promise API
  • Loading branch information
dthree committed May 19, 2016
2 parents 4f48a46 + eac3f65 commit ba47fe6
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 104 deletions.
24 changes: 12 additions & 12 deletions dist/commands/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ var alias = {
// alias foo=bar, or
// alias foo 'bar and so on'.
var key = args.join(' ');
var value = undefined;
var value = void 0;
if (String(key).indexOf('=') > -1) {
var parts = String(key).trim().split('=');
key = parts[0];
value = parts[1] || value;
} else {
var parts = String(key).trim().split(' ');
key = parts.shift();
value = parts.join(' ');
var _parts = String(key).trim().split(' ');
key = _parts.shift();
value = _parts.join(' ');
}

// Remove wrapped quotes from value.
Expand All @@ -44,7 +44,7 @@ var alias = {
}

// Pull list of aliases
var all = undefined;
var all = void 0;
try {
all = JSON.parse(vorpal.localStorage.getItem('aliases') || []);
} catch (e) {
Expand All @@ -67,19 +67,19 @@ var alias = {
});
all.push(key);
} else {
var item = vorpal.localStorage.getItem('alias|' + key);
if (item !== undefined && item !== null) {
this.log('alias ' + key + '=\'' + item + '\'');
var _item = vorpal.localStorage.getItem('alias|' + key);
if (_item !== undefined && _item !== null) {
this.log('alias ' + key + '=\'' + _item + '\'');
} else {
this.log('-cash: alias: ' + key + ': not found');
}
}

var aliases = {};
for (var i = 0; i < all.length; ++i) {
var item = vorpal.localStorage.getItem('alias|' + all[i]);
if (item !== undefined && item !== null) {
aliases[all[i]] = item;
for (var _i = 0; _i < all.length; ++_i) {
var _item2 = vorpal.localStorage.getItem('alias|' + all[_i]);
if (_item2 !== undefined && _item2 !== null) {
aliases[all[_i]] = _item2;
}
}
vorpal._aliases = aliases;
Expand Down
4 changes: 2 additions & 2 deletions dist/commands/cd.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var cd = {
}
},
error: function error(e, dir) {
var status = undefined;
var stdout = undefined;
var status = void 0;
var stdout = void 0;
if (e.code === 'ENOENT' && e.syscall === 'uv_chdir') {
status = 1;
stdout = '-bash: cd: ' + dir + ': No such file or directory';
Expand Down
6 changes: 3 additions & 3 deletions dist/commands/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ var _export = {
}
}
} else {
var parts = String(id).trim().split(' ');
id = parts.shift();
value = parts.join(' ') || null;
var _parts = String(id).trim().split(' ');
id = _parts.shift();
value = _parts.join(' ') || null;
}

var validIdRegex = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
Expand Down
4 changes: 2 additions & 2 deletions dist/commands/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var rm = {

function rmdirSyncRecursive(dir, force, removeEmptyDir) {
var self = this;
var files = undefined;
var files = void 0;
files = fs.readdirSync(dir);

// Loop through and delete everything in the sub-tree after checking it
Expand Down Expand Up @@ -102,7 +102,7 @@ function rmdirSyncRecursive(dir, force, removeEmptyDir) {

// Now that we know everything in the sub-tree has been deleted,
// we can delete the main directory.
var result = undefined;
var result = void 0;
try {
// Retry on windows, sometimes it takes a little time before all the files in the directory are gone
var start = Date.now();
Expand Down
16 changes: 8 additions & 8 deletions dist/commands/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ var sort = {
if (options.check) {
// Check if the thing was already sorted.
var original = String(combined).split('\n');
var disorder = undefined;
for (var i = 0; i < original.length; ++i) {
var a = original[i];
var b = original[i + 1];
var disorder = void 0;
for (var _i = 0; _i < original.length; ++_i) {
var a = original[_i];
var b = original[_i + 1];
if (a && b) {
if (!isNaN(a) && !isNaN(b) && parseFloat(a) > parseFloat(b)) {
/* istanbul ignore next */
Expand All @@ -124,7 +124,7 @@ var sort = {
// name of the bad sorted item - I have to
// figure this out as I join all the files
// together beforehand and lose track.
disorder = 'sort: -:' + (i + 2) + ': disorder: ' + b;
disorder = 'sort: -:' + (_i + 2) + ': disorder: ' + b;
break;
}
}
Expand Down Expand Up @@ -162,9 +162,9 @@ var sort = {
}
return result;
} else if (options.numericsort) {
var result = aNumeric - bNumeric;
result = result === 0 ? aAlpha.localeCompare(bAlpha) : result;
return result;
var _result = aNumeric - bNumeric;
_result = _result === 0 ? aAlpha.localeCompare(bAlpha) : _result;
return _result;
}
return aAlpha.localeCompare(bAlpha);
});
Expand Down
2 changes: 1 addition & 1 deletion dist/commands/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ var touch = {
var mtime = options.a === true ? new Date(stat.mtime) : dateToSet;

if (options.reference !== undefined) {
var reference = undefined;
var reference = void 0;
try {
reference = fs.statSync(options.reference);
} catch (e) {
Expand Down
8 changes: 4 additions & 4 deletions dist/commands/unalias.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var unalias = {
}

// Pull list of aliases
var all = undefined;
var all = void 0;
try {
all = JSON.parse(vorpal.localStorage.getItem('aliases') || []);
} catch (e) {
Expand Down Expand Up @@ -68,10 +68,10 @@ var unalias = {
// Rebuild alias lists.
var aliases = {};
/* istanbul ignore next */
for (var i = 0; i < all.length; ++i) {
var item = vorpal.localStorage.getItem('alias|' + all[i]);
for (var _i = 0; _i < all.length; ++_i) {
var item = vorpal.localStorage.getItem('alias|' + all[_i]);
if (item !== undefined && item !== null) {
aliases[all[i]] = item;
aliases[all[_i]] = item;
}
}
vorpal._aliases = aliases;
Expand Down
30 changes: 15 additions & 15 deletions dist/delimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ var pathConverter = require('./util/converter.path');
module.exports = {
refresh: function refresh(vorpal, cb) {
cb = cb || function () {};
username(function (err, username) {
if (!err) {
var user = username;
var host = String(os.hostname()).split('.')[0];
var home = pathConverter.unix(userHome);
var cwd = pathConverter.unix(process.cwd());
cwd = cwd.replace(home, '~');
var delimiter = user + '@' + host + ':' + cwd + '$';
// If we're on linux-based systems, color
// the prompt so we don't get confused.
if (!isWindows) {
delimiter = '\u001b[32m' + delimiter + '\u001b[39m';
}
vorpal.delimiter(delimiter);
username().then(function (username) {
var user = username;
var host = String(os.hostname()).split('.')[0];
var home = pathConverter.unix(userHome);
var cwd = pathConverter.unix(process.cwd());
cwd = cwd.replace(home, '~');
var delimiter = user + '@' + host + ':' + cwd + '$';
// If we're on linux-based systems, color
// the prompt so we don't get confused.
if (!isWindows) {
delimiter = '\u001b[32m' + delimiter + '\u001b[39m';
}
cb(err);
vorpal.delimiter(delimiter);
cb(null);
}).catch(function (err) {
return cb(err);
});
},
getHomeDir: function getHomeDir() {
Expand Down
4 changes: 2 additions & 2 deletions dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
6 changes: 3 additions & 3 deletions dist/util/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ module.exports = function (files, stdin, options) {
var agg = files.length < 1 ? stdin : files;
var final = [];

for (var i = 0; i < agg.length; ++i) {
if (agg[i] !== undefined) {
final.push(agg[i]);
for (var _i = 0; _i < agg.length; ++_i) {
if (agg[_i] !== undefined) {
final.push(agg[_i]);
}
}
return final;
Expand Down
6 changes: 3 additions & 3 deletions dist/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ module.exports = {
var slf = this;

var words = args.words.join(' ');
var argus = undefined;
var argus = void 0;

var cmd = undefined;
var cmd = void 0;
// Only register commands if on Windows.
/* istanbul ignore next */
if (windows) {
Expand Down Expand Up @@ -67,7 +67,7 @@ module.exports = {

argus.unshift(cmd);
argus.unshift('/C');
var proc = undefined;
var proc = void 0;
var out = '';
try {
proc = spawn('cmd', argus);
Expand Down
4 changes: 2 additions & 2 deletions packages/cat/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
6 changes: 3 additions & 3 deletions packages/cat/dist/util/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ module.exports = function (files, stdin, options) {
var agg = files.length < 1 ? stdin : files;
var final = [];

for (var i = 0; i < agg.length; ++i) {
if (agg[i] !== undefined) {
final.push(agg[i]);
for (var _i = 0; _i < agg.length; ++_i) {
if (agg[_i] !== undefined) {
final.push(agg[_i]);
}
}
return final;
Expand Down
4 changes: 2 additions & 2 deletions packages/cp/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
4 changes: 2 additions & 2 deletions packages/head/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
4 changes: 2 additions & 2 deletions packages/ls/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
4 changes: 2 additions & 2 deletions packages/mv/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
4 changes: 2 additions & 2 deletions packages/rm/dist/commands/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var rm = {

function rmdirSyncRecursive(dir, force, removeEmptyDir) {
var self = this;
var files = undefined;
var files = void 0;
files = fs.readdirSync(dir);

// Loop through and delete everything in the sub-tree after checking it
Expand Down Expand Up @@ -102,7 +102,7 @@ function rmdirSyncRecursive(dir, force, removeEmptyDir) {

// Now that we know everything in the sub-tree has been deleted,
// we can delete the main directory.
var result = undefined;
var result = void 0;
try {
// Retry on windows, sometimes it takes a little time before all the files in the directory are gone
var start = Date.now();
Expand Down
4 changes: 2 additions & 2 deletions packages/rm/dist/util/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = function (list) {
files[i] = res.length > 0 ? res : list[i];
}
var out = [];
for (var i = 0; i < files.length; ++i) {
out = Array.isArray(files[i]) ? out.concat(files[i]) : out.concat([files[i]]);
for (var _i = 0; _i < files.length; ++_i) {
out = Array.isArray(files[_i]) ? out.concat(files[_i]) : out.concat([files[_i]]);
}
return out;
};
16 changes: 8 additions & 8 deletions packages/sort/dist/commands/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ var sort = {
if (options.check) {
// Check if the thing was already sorted.
var original = String(combined).split('\n');
var disorder = undefined;
for (var i = 0; i < original.length; ++i) {
var a = original[i];
var b = original[i + 1];
var disorder = void 0;
for (var _i = 0; _i < original.length; ++_i) {
var a = original[_i];
var b = original[_i + 1];
if (a && b) {
if (!isNaN(a) && !isNaN(b) && parseFloat(a) > parseFloat(b)) {
/* istanbul ignore next */
Expand All @@ -124,7 +124,7 @@ var sort = {
// name of the bad sorted item - I have to
// figure this out as I join all the files
// together beforehand and lose track.
disorder = 'sort: -:' + (i + 2) + ': disorder: ' + b;
disorder = 'sort: -:' + (_i + 2) + ': disorder: ' + b;
break;
}
}
Expand Down Expand Up @@ -162,9 +162,9 @@ var sort = {
}
return result;
} else if (options.numericsort) {
var result = aNumeric - bNumeric;
result = result === 0 ? aAlpha.localeCompare(bAlpha) : result;
return result;
var _result = aNumeric - bNumeric;
_result = _result === 0 ? aAlpha.localeCompare(bAlpha) : _result;
return _result;
}
return aAlpha.localeCompare(bAlpha);
});
Expand Down
Loading

0 comments on commit ba47fe6

Please sign in to comment.