Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing bash-parser dependency #112

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -29,3 +29,5 @@ node_modules
.cmd_history
.cmd_history/*
.cmd_history/cmd_historycash

dist/*
2 changes: 1 addition & 1 deletion dist/commands/clear.js
Expand Up @@ -4,7 +4,7 @@ var interfacer = require('./../util/interfacer');

var clear = {
exec: function exec() {
this.log('\u001b[2J\u001b[0;0H');
this.log('\x1B[2J\x1B[0;0H');
return 0;
}
};
Expand Down
8 changes: 4 additions & 4 deletions dist/commands/cp.js
Expand Up @@ -140,10 +140,10 @@ function cpdirSyncRecursive(sourceDir, destDir, options) {
fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null);
// At this point, we've hit a file actually worth copying... so copy it on over.
} else if (fs.existsSync(destFile) && options.noclobber) {
// be silent
} else {
copyFileSync.call(self, srcFile, destFile);
}
// be silent
} else {
copyFileSync.call(self, srcFile, destFile);
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion dist/commands/head.js
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var interfacer = require('./../util/interfacer');
var fs = require('fs');
Expand All @@ -10,6 +10,7 @@ var expand = require('./../util/expand');

var head = {
exec: function exec(args, options) {
console.log({ args: args });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would you want this?

options = options || {};
args = args || '';
var source = args.stdin === undefined ? 'files' : 'stdin';
Expand Down
2 changes: 1 addition & 1 deletion dist/commands/ls.js
@@ -1,6 +1,6 @@
'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

var chalk = require('chalk');
var filesize = require('filesize');
Expand Down
12 changes: 6 additions & 6 deletions dist/commands/rm.js
Expand Up @@ -123,12 +123,12 @@ function rmdirSyncRecursive(dir, force, removeEmptyDir) {
}
/* istanbul ignore next */
} else if (er.code === 'ENOENT') {
// Directory did not exist, deletion was successful
break;
/* istanbul ignore next */
} else {
throw er;
}
// Directory did not exist, deletion was successful
break;
/* istanbul ignore next */
} else {
throw er;
}
}
}
} catch (e) {
Expand Down
6 changes: 3 additions & 3 deletions dist/commands/unalias.js
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
2 changes: 1 addition & 1 deletion dist/delimiter.js
Expand Up @@ -20,7 +20,7 @@ module.exports = {
// If we're on linux-based systems, color
// the prompt so we don't get confused.
if (!isWindows) {
delimiter = '\u001b[32m' + delimiter + '\u001b[39m';
delimiter = '\x1B[32m' + delimiter + '\x1B[39m';
}
vorpal.delimiter(delimiter);
cb(null);
Expand Down
65 changes: 30 additions & 35 deletions dist/index.js
Expand Up @@ -68,26 +68,24 @@ var app = {
return;
}
try {
(function () {
var mod = require('./commands/' + cmd + '.js');
var help = void 0;
try {
help = require('./help/' + cmd + '.js');
help = String(help).replace(/^\n|\n$/g, '');
} catch (e) {
// .. whatever
}
self.vorpal.use(mod, {
parent: self
var mod = require('./commands/' + cmd + '.js');
var _help = void 0;
try {
_help = require('./help/' + cmd + '.js');
_help = String(_help).replace(/^\n|\n$/g, '');
} catch (e) {
// .. whatever
}
self.vorpal.use(mod, {
parent: self
});
var cmdObj = self.vorpal.find(cmd);
if (cmdObj && _help) {
/* istanbul ignore next */
cmdObj.help(function (args, cb) {
cb(_help);
});
var cmdObj = self.vorpal.find(cmd);
if (cmdObj && help) {
/* istanbul ignore next */
cmdObj.help(function (args, cb) {
cb(help);
});
}
})();
}
} catch (e) {
/* istanbul ignore next */
self.vorpal.log('Error loading command ' + cmd + ': ', e);
Expand Down Expand Up @@ -169,21 +167,19 @@ var app = {
// for dev testing.
/* istanbul ignore next */
if (os.platform().indexOf('win') > -1) {
(function () {
var counter = 0;
setInterval(function () {
counter = counter > 0 ? 0 : counter;
}, 3000);
app.vorpal.sigint(function () {
counter++;
app.vorpal.ui.submit('');
if (counter > 5) {
app.vorpal.log('(to quit Cash, use the "exit" command)');
counter -= 10000;
}
return;
});
})();
var counter = 0;
setInterval(function () {
counter = counter > 0 ? 0 : counter;
}, 3000);
app.vorpal.sigint(function () {
counter++;
app.vorpal.ui.submit('');
if (counter > 5) {
app.vorpal.log('(to quit Cash, use the "exit" command)');
counter -= 10000;
}
return;
});
}

// Load .cashrc upon startup
Expand Down Expand Up @@ -215,7 +211,6 @@ var app = {

cmds = {
/* istanbul ignore next */

show: function show() {
/* istanbul ignore next */
app.vorpal.show();
Expand Down
10 changes: 5 additions & 5 deletions dist/lib/sugar.js
@@ -1,6 +1,6 @@
"use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

/*
* Sugar Library v1.4.1
Expand Down Expand Up @@ -146,7 +146,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
Ja = "",
Ka = {},
La;function Ma() {
return "\t\n\u000b\f\r   ᠎             \u2028\u2029 ";
return "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u2028\u2029\u3000\uFEFF";
}function Na(a, b) {
var c = "";for (a = a.toString(); 0 < b;) {
if (b & 1 && (c += a), b >>= 1) a += a;
Expand Down Expand Up @@ -216,7 +216,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
});var Za, $a;
for ($a = 0; 9 >= $a; $a++) {
Za = s.fromCharCode($a + Ga), Ja += Za, Ka[Za] = s.fromCharCode($a + Ea);
}Ka[","] = "";Ka[""] = Ia;Ka[Ia] = Ia;La = q("[" + Ja + "," + Ia + "]", "g");
}Ka[","] = "";Ka["\uFF0E"] = Ia;Ka[Ia] = Ia;La = q("[" + Ja + "\uFF0E," + Ia + "]", "g");
"use strict";H(m, !1, !1, { keys: function keys(a) {
var b = [];if (!G(a) && !D(a) && !F(a)) throw new TypeError("Object required");I(a, function (a) {
b.push(a);
Expand Down Expand Up @@ -725,9 +725,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
return qc(this, b, !1, a);
};
});
"〇一二三四五六七八九十百千万".split("").forEach(function (a, b) {
"\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u767E\u5343\u4E07".split("").forEach(function (a, b) {
9 < b && (b = za(10, b - 9));Lb[a] = b;
});xa(Lb, Ka);Mb = q("([期週周])?([〇一二三四五六七八九十百千万" + Ja + "]+)(?!)", "g");
});xa(Lb, Ka);Mb = q("([\u671F\u9031\u5468])?([\u3007\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341\u767E\u5343\u4E07" + Ja + "]+)(?!\u6628)", "g");
/* istanbul ignore next */
(function () {
var a = W.weekdays.slice(0, 7),
Expand Down
4 changes: 2 additions & 2 deletions dist/preparser.js
Expand Up @@ -4,7 +4,7 @@

var parseEnvVariables = function parseEnvVariables(input) {
var referenceRegex = /\${([a-zA-Z_][a-zA-Z0-9_]*)}|\$([a-zA-Z_][a-zA-Z0-9_]*)/g;

console.log({ input: input });
return input.replace(referenceRegex, function (varRef, capture1, capture2, capture3) {
var varName = capture1 || capture2 || capture3;
// Return the value of the variable, or the empty string if not there
Expand All @@ -13,7 +13,7 @@ var parseEnvVariables = function parseEnvVariables(input) {
};

var preparser = function preparser(input) {
input = parseEnvVariables(input);
// input = parseEnvVariables(input);
return input;
};

Expand Down
2 changes: 1 addition & 1 deletion dist/util/colorFile.js
Expand Up @@ -6,7 +6,7 @@ var chalk = {};
var map = { cyan: 36, red: 31, magenta: 35 };
Object.keys(map).forEach(function (key, value) {
chalk[key] = function (str) {
return '\u001b[' + value + 'm' + str + '\u001b[39m';
return '\x1B[' + value + 'm' + str + '\x1B[39m';
};
});

Expand Down