From 964ce3c073bb447c2afe596d036e5433872f2563 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 18 May 2016 22:36:27 +0200 Subject: [PATCH 1/2] =?UTF-8?q?use=20the=20`username`=20module=E2=80=99s?= =?UTF-8?q?=20Promise=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since version 2.0.0, the `username` module returns Promise instances rather than using callbacks. --- src/delimiter.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/delimiter.js b/src/delimiter.js index 641b2c0..f9217cf 100755 --- a/src/delimiter.js +++ b/src/delimiter.js @@ -11,23 +11,21 @@ module.exports = { refresh(vorpal, cb) { cb = cb || function () {}; - username(function (err, username) { - if (!err) { - const user = username; - const host = String(os.hostname()).split('.')[0]; - const home = pathConverter.unix(userHome); - let cwd = pathConverter.unix(process.cwd()); - cwd = cwd.replace(home, '~'); - let 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(username => { + const user = username; + const host = String(os.hostname()).split('.')[0]; + const home = pathConverter.unix(userHome); + let cwd = pathConverter.unix(process.cwd()); + cwd = cwd.replace(home, '~'); + let 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(err => cb(err)); }, getHomeDir() { From eac3f654b58bbc1a24ef97ed23e82bc7a181cf00 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 19 May 2016 01:13:54 +0200 Subject: [PATCH 2/2] update dist/ --- dist/commands/alias.js | 24 ++++++++++----------- dist/commands/cd.js | 4 ++-- dist/commands/export.js | 6 +++--- dist/commands/rm.js | 4 ++-- dist/commands/sort.js | 16 +++++++------- dist/commands/touch.js | 2 +- dist/commands/unalias.js | 8 +++---- dist/delimiter.js | 30 +++++++++++++-------------- dist/util/expand.js | 4 ++-- dist/util/fetch.js | 6 +++--- dist/windows.js | 6 +++--- packages/cat/dist/util/expand.js | 4 ++-- packages/cat/dist/util/fetch.js | 6 +++--- packages/cp/dist/util/expand.js | 4 ++-- packages/head/dist/util/expand.js | 4 ++-- packages/ls/dist/util/expand.js | 4 ++-- packages/mv/dist/util/expand.js | 4 ++-- packages/rm/dist/commands/rm.js | 4 ++-- packages/rm/dist/util/expand.js | 4 ++-- packages/sort/dist/commands/sort.js | 16 +++++++------- packages/sort/dist/util/expand.js | 4 ++-- packages/sort/dist/util/fetch.js | 6 +++--- packages/tail/dist/util/expand.js | 4 ++-- packages/touch/dist/commands/touch.js | 2 +- 24 files changed, 88 insertions(+), 88 deletions(-) diff --git a/dist/commands/alias.js b/dist/commands/alias.js index 39aed34..87f44e2 100755 --- a/dist/commands/alias.js +++ b/dist/commands/alias.js @@ -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. @@ -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) { @@ -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; diff --git a/dist/commands/cd.js b/dist/commands/cd.js index af243c2..457447d 100755 --- a/dist/commands/cd.js +++ b/dist/commands/cd.js @@ -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'; diff --git a/dist/commands/export.js b/dist/commands/export.js index a00efac..07154a9 100755 --- a/dist/commands/export.js +++ b/dist/commands/export.js @@ -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_]*$/; diff --git a/dist/commands/rm.js b/dist/commands/rm.js index 7866517..602b134 100755 --- a/dist/commands/rm.js +++ b/dist/commands/rm.js @@ -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 @@ -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(); diff --git a/dist/commands/sort.js b/dist/commands/sort.js index 1d398f5..ff85a63 100755 --- a/dist/commands/sort.js +++ b/dist/commands/sort.js @@ -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 */ @@ -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; } } @@ -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); }); diff --git a/dist/commands/touch.js b/dist/commands/touch.js index e70def2..ab2e362 100755 --- a/dist/commands/touch.js +++ b/dist/commands/touch.js @@ -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) { diff --git a/dist/commands/unalias.js b/dist/commands/unalias.js index 191744e..971265a 100755 --- a/dist/commands/unalias.js +++ b/dist/commands/unalias.js @@ -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) { @@ -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; diff --git a/dist/delimiter.js b/dist/delimiter.js index 5cffe5d..30eddc1 100755 --- a/dist/delimiter.js +++ b/dist/delimiter.js @@ -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() { diff --git a/dist/util/expand.js b/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/dist/util/expand.js +++ b/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/dist/util/fetch.js b/dist/util/fetch.js index da862df..9edd8a2 100755 --- a/dist/util/fetch.js +++ b/dist/util/fetch.js @@ -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; diff --git a/dist/windows.js b/dist/windows.js index 2dcfddc..a038a11 100755 --- a/dist/windows.js +++ b/dist/windows.js @@ -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) { @@ -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); diff --git a/packages/cat/dist/util/expand.js b/packages/cat/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/cat/dist/util/expand.js +++ b/packages/cat/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/cat/dist/util/fetch.js b/packages/cat/dist/util/fetch.js index da862df..9edd8a2 100755 --- a/packages/cat/dist/util/fetch.js +++ b/packages/cat/dist/util/fetch.js @@ -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; diff --git a/packages/cp/dist/util/expand.js b/packages/cp/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/cp/dist/util/expand.js +++ b/packages/cp/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/head/dist/util/expand.js b/packages/head/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/head/dist/util/expand.js +++ b/packages/head/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/ls/dist/util/expand.js b/packages/ls/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/ls/dist/util/expand.js +++ b/packages/ls/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/mv/dist/util/expand.js b/packages/mv/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/mv/dist/util/expand.js +++ b/packages/mv/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/rm/dist/commands/rm.js b/packages/rm/dist/commands/rm.js index 7866517..602b134 100755 --- a/packages/rm/dist/commands/rm.js +++ b/packages/rm/dist/commands/rm.js @@ -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 @@ -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(); diff --git a/packages/rm/dist/util/expand.js b/packages/rm/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/rm/dist/util/expand.js +++ b/packages/rm/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/sort/dist/commands/sort.js b/packages/sort/dist/commands/sort.js index 1d398f5..ff85a63 100755 --- a/packages/sort/dist/commands/sort.js +++ b/packages/sort/dist/commands/sort.js @@ -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 */ @@ -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; } } @@ -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); }); diff --git a/packages/sort/dist/util/expand.js b/packages/sort/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/sort/dist/util/expand.js +++ b/packages/sort/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/sort/dist/util/fetch.js b/packages/sort/dist/util/fetch.js index da862df..9edd8a2 100755 --- a/packages/sort/dist/util/fetch.js +++ b/packages/sort/dist/util/fetch.js @@ -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; diff --git a/packages/tail/dist/util/expand.js b/packages/tail/dist/util/expand.js index 49e12a5..d04097b 100755 --- a/packages/tail/dist/util/expand.js +++ b/packages/tail/dist/util/expand.js @@ -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; }; \ No newline at end of file diff --git a/packages/touch/dist/commands/touch.js b/packages/touch/dist/commands/touch.js index e70def2..ab2e362 100755 --- a/packages/touch/dist/commands/touch.js +++ b/packages/touch/dist/commands/touch.js @@ -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) {