Socket
Socket
Sign inDemoInstall

git-bash-shell

Package Overview
Dependencies
158
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.0 to 2.4.0

lib/charset.js

181

lib/cli-environment.js

@@ -13,2 +13,4 @@ "use strict";

var aliasWin = require("alias-win");
var gitWin = require("git-win");

@@ -28,2 +30,34 @@

function getDefaultAliases() {
var gitPath = function gitPath(file) {
return path.join("%GIT_INSTALL_ROOT%", file);
};
var env = function env(cmds) {
return cmds ? `env.exe ${cmds} $*` : "env.exe $*";
};
var shell = function shell(_shell) {
return env(`"SHELL=${gitPath(_shell)}" ${path.basename(_shell, ".exe")}`);
};
var js = function js(_js) {
return env(`node "${require.resolve(_js)}"`);
};
var sh = shell("/bin/sh");
return {
alias: js("alias-win/bin/alias"),
unalias: js("alias-win/bin/unalias"),
npx: env("npx"),
npm: env("npm"),
bash: shell("/bin/bash"),
dash: shell("/bin/dash"),
zsh: shell("/usr/bin/zsh"),
sh,
env: `if defined SHELL ( ${env()} ) else ( ${env(`"SHELL=${gitPath("bin/sh")}" env.exe`)} )`,
"$SHELL": `if defined SHELL ( ${env("\"%SHELL%\"")} ) else ( ${sh} )`
};
}
function set(key, value) {

@@ -37,65 +71,2 @@ value = value || process.env[key];

var defaultAlias = {
"ll": "ls -l $*",
"ls": "ls -F --color=auto --show-control-chars $*",
"swi": "sudo winpty $*",
"wi": "winpty $*"
};
function updateAlias(_x) {
return _updateAlias.apply(this, arguments);
}
function _updateAlias() {
_updateAlias = (0, _asyncToGenerator2.default)(
/*#__PURE__*/
_regenerator.default.mark(function _callee(alias) {
var aliaKeys, doskey;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
aliaKeys = Object.keys(alias);
if (aliaKeys.length) {
_context.next = 3;
break;
}
return _context.abrupt("return");
case 3:
/*
const fileName = path.join(__dirname, "../bin/git-bash-shell.cmd");
const rawCmds = await promisify(fs.readFile)(fileName, "utf8");
const newAlias = Object.assign({}, defaultAlias, alias);
const newCmds = (rawCmds).split(/[\r\n]+/g).filter(line => line[0] === ";").concat(
Object.keys(newAlias).map(key => `${key}=${newAlias[key]}`),
""
).join("\r\n");
if (rawCmds === newCmds) {
return;
}
try {
await promisify(fs.writeFile)(fileName, newCmds);
return;
} catch (ex) {
//
}
*/
doskey = `"${path.join(process.env.windir || process.env.SystemRoot, "System32/doskey.exe")}"`;
console.log(aliaKeys.map(function (key) {
return `${doskey} ${key}=${alias[key]}`;
}).join("\r\n"));
case 5:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return _updateAlias.apply(this, arguments);
}
function login() {

@@ -108,7 +79,7 @@ return _login.apply(this, arguments);

/*#__PURE__*/
_regenerator.default.mark(function _callee2() {
var envPath, HOME, env, alias;
return _regenerator.default.wrap(function _callee2$(_context2) {
_regenerator.default.mark(function _callee() {
var envPath, HOME, env, rawAliases, aliases, name;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context2.prev = _context2.next) {
switch (_context.prev = _context.next) {
case 0:

@@ -123,3 +94,3 @@ envPath = gitWin.toWin32("/usr/bin/env.exe");

HOME = gitWin.toPosix(process.env.HOME);
_context2.next = 5;
_context.next = 5;
return spawn([envPath, "--ignore-environment", "HOME=" + HOME, process.env.SHELL || "/bin/bash", "--login", "-c", "env && alias -p"], {

@@ -133,4 +104,9 @@ env: {

case 5:
env = _context2.sent;
alias = {};
env = _context.sent;
_context.next = 8;
return aliasWin.get();
case 8:
rawAliases = _context.sent;
aliases = Object.assign(getDefaultAliases(), rawAliases);
env.split(/[\r\n]+/g).forEach(function (env) {

@@ -145,9 +121,5 @@ if (!env || /^(?:!.+|_|(?:ORIGINAL|MSYSTEM|MINGW)(?:_.+)?|HOME|PWD|SHELL|TERM|PS1|SHLVL|SYSTEMROOT|WINDIR)=/i.test(env) || /=\/mingw\d+(?=\/|$)/.test(env)) {

} else if (/^alias\s+(.*?)\s*=\s*(['"])?(.*)\2$/.test(env)) {
var key = RegExp.$1;
var value = RegExp.$3.replace(/\s*$/, " $*");
if (!defaultAlias[key] || defaultAlias[key] !== value) {
alias[key] = value;
}
var key = RegExp.$1,
value = RegExp.$3;
aliases[key] = value.replace(/\s*$/, " $*");
return;

@@ -158,11 +130,18 @@ }

});
_context2.next = 10;
return updateAlias(alias);
case 10:
for (name in rawAliases) {
if (aliases[name] === rawAliases[name]) {
delete aliases[name];
}
}
_context.next = 14;
return aliasWin.set(aliases);
case 14:
case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2, this);
}, _callee, this);
}));

@@ -179,8 +158,8 @@ return _login.apply(this, arguments);

/*#__PURE__*/
_regenerator.default.mark(function _callee4() {
_regenerator.default.mark(function _callee3() {
var nodeDir, readFile, read, _read, npmConfig;
return _regenerator.default.wrap(function _callee4$(_context4) {
return _regenerator.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context4.prev = _context4.next) {
switch (_context3.prev = _context3.next) {
case 0:

@@ -190,28 +169,28 @@ _read = function _ref2() {

/*#__PURE__*/
_regenerator.default.mark(function _callee3(file) {
_regenerator.default.mark(function _callee2(file) {
var ini, contents;
return _regenerator.default.wrap(function _callee3$(_context3) {
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context3.prev = _context3.next) {
switch (_context2.prev = _context2.next) {
case 0:
_context3.prev = 0;
_context2.prev = 0;
ini = require(path.join(nodeDir, "node_modules/npm/node_modules/ini/ini.js"));
_context3.next = 4;
_context2.next = 4;
return readFile(file, "utf8");
case 4:
contents = _context3.sent;
return _context3.abrupt("return", ini.parse(contents));
contents = _context2.sent;
return _context2.abrupt("return", ini.parse(contents));
case 8:
_context3.prev = 8;
_context3.t0 = _context3["catch"](0);
return _context3.abrupt("return", {});
_context2.prev = 8;
_context2.t0 = _context2["catch"](0);
return _context2.abrupt("return", {});
case 11:
case "end":
return _context3.stop();
return _context2.stop();
}
}
}, _callee3, this, [[0, 8]]);
}, _callee2, this, [[0, 8]]);
}));

@@ -221,3 +200,3 @@ return _read.apply(this, arguments);

read = function _ref(_x2) {
read = function _ref(_x) {
return _read.apply(this, arguments);

@@ -232,3 +211,3 @@ };

};
_context4.next = 7;
_context3.next = 7;
return Promise.all([path.join(npmConfig.prefix, "etc/npmrc"), path.join(os.homedir(), ".npmrc"), ".npmrc"].map(read)).then(function (config) {

@@ -245,6 +224,6 @@ Object.assign.apply(Object, [npmConfig].concat((0, _toConsumableArray2.default)(config)));

case "end":
return _context4.stop();
return _context3.stop();
}
}
}, _callee4, this);
}, _callee3, this);
}));

@@ -251,0 +230,0 @@ return _npmrc.apply(this, arguments);

@@ -13,2 +13,4 @@ "use strict";

var charset = require("./charset");
var gitWin = require("git-win");

@@ -25,2 +27,6 @@

var curl = gitWin.toWin32("/mingw00/bin/curl.exe");
var readFile = promisify(fs.readFile);
var writeFile = promisify(fs.writeFile);
var readdir = promisify(fs.readdir);
var mkdir = promisify(fs.mkdir);

@@ -121,3 +127,3 @@ function autoRun() {

_context3.next = 3;
return promisify(fs.readdir)(cmderDir);
return readdir(cmderDir);

@@ -133,3 +139,3 @@ case 3:

_context3.next = 10;
return promisify(fs.mkdir)(cmderDir);
return mkdir(cmderDir);

@@ -265,3 +271,3 @@ case 10:

_context5.next = 26;
return promisify(fs.readFile)(clinkFile, "utf8");
return readFile(clinkFile, "utf8");

@@ -278,3 +284,3 @@ case 26:

_context5.next = 31;
return promisify(fs.writeFile)(clinkFile, clinkConfig);
return writeFile(clinkFile, clinkConfig);

@@ -306,3 +312,3 @@ case 31:

_context6.next = 3;
return promisify(fs.readFile)(cmdFile, "utf8");
return readFile(cmdFile, "utf8");

@@ -314,3 +320,3 @@ case 3:

_context6.next = 8;
return promisify(fs.writeFile)(cmdFile, cmd);
return writeFile(cmdFile, cmd);

@@ -327,3 +333,3 @@ case 8:

module.exports = Promise.all([autoRun(), getCmder(), cmd()]).then(function () {
module.exports = Promise.all([autoRun(), charset(), getCmder(), cmd()]).then(function () {
console.log("`git-bash-shell` installation was successful, please restart your terminal!");

@@ -330,0 +336,0 @@ }, function (error) {

@@ -26,5 +26,9 @@ "use strict";

}
// case 'REG_QWORD': {
// value = hexToUint8Array(value);
// break;
case "REG_BINARY":
{
return binToUint8Array(value);
}
// case "REG_QWORD": {
// return hexToUint8Array(value);
// }

@@ -38,6 +42,6 @@ }

// if ((hex.length % 2) !== 0) {
// hex = '0' + hex;
// hex = "0" + hex;
// }
// var view = new Uint8Array(hex.length / 2);
// for (var i = 0; i < hex.length; i += 2) {
// const view = new Uint8Array(hex.length / 2);
// for (let i = 0; i < hex.length; i += 2) {
// view[i / 2] = parseInt(prefix + hex.slice(i, i + 2));

@@ -47,3 +51,13 @@ // }

// }
// function strToHex (value) {
function binToUint8Array(bin) {
var view = new Uint8Array(bin.length / 2);
for (var i = 0; i < bin.length; i += 2) {
view[i / 2] = parseInt(bin.slice(i, i + 2), 16);
}
return view;
} // function strToHex (value) {
// if (!value) {

@@ -121,3 +135,3 @@ // return '-';

_regenerator.default.mark(function _callee2(key) {
var stdout;
var result, stdout, prefix, currKey;
return _regenerator.default.wrap(function _callee2$(_context2) {

@@ -127,4 +141,5 @@ while (1) {

case 0:
_context2.next = 2;
return spawn([regExe, "QUERY", key, "/reg:" + osArch], {
result = {};
_context2.next = 3;
return spawn([regExe, "QUERY", key, "/s", "/reg:" + osArch], {
argv0: "reg",

@@ -134,20 +149,31 @@ encoding: "utf8"

case 2:
case 3:
stdout = _context2.sent;
return _context2.abrupt("return", new Proxy({}, {
get: function get(target, name) {
if (typeof name === "string" && !target[name]) {
var _key = new RegExp(`^\\s+${name}\\s+(REG(?:_[A-Z]+)+)\\s+(.+)$`, "im").exec(stdout);
currKey = result;
stdout.split(/[\r\n]+/g).forEach(function (line) {
if (line.startsWith("HKEY_")) {
if (prefix == null) {
prefix = "";
key = line.slice(0, line.indexOf("\\") + key.replace(/^\w+/, "").length);
}
if (_key) {
target[name] = _key[2];
return parseValue(_key[1], _key[2]);
prefix = line.slice(key.length + 1);
currKey = result;
prefix.split(/\\/g).filter(Boolean).forEach(function (key) {
if (!currKey[key]) {
currKey[key] = {};
}
}
return target[name];
currKey = currKey[key];
});
} else if (/^\s+(.*?)\s+(REG_[A-Z_]+)\s+(.*?)$/.test(line)) {
var _key = RegExp.$1,
type = RegExp.$2,
value = RegExp.$3;
currKey[_key] = parseValue(type, value);
}
}));
});
return _context2.abrupt("return", result);
case 4:
case 7:
case "end":

@@ -154,0 +180,0 @@ return _context2.stop();

@@ -8,96 +8,4 @@ "use strict";

var stdcp;
var magic = {
// Japanese
"932": "Shift_JIS",
"20932": "EUC-JP",
"51932": "EUC-JP",
// Simplified Chinese
"936": "GB2312",
"20936": "GB2312-80",
"51936": "EUC-CN",
"52936": "HZ-GB2312",
"54936": "GB18030",
// Korean:
"949": "KS_C_5601",
"51949": "EUC-KR",
// Traditional Chinese
"950": "Big5",
"51950": "EUC-TW",
// macintosh
"10000": "mac-roman",
"10001": "mac-japanese",
"10002": "mac-chinesetrad",
"10003": "mac-korean",
"10004": "mac-arabic",
"10005": "mac-hebrew",
"10006": "mac-greek",
"10007": "mac-cyrillic",
"10008": "mac-chinesesimp",
"10010": "mac-romanian",
"10017": "mac-ukrainian",
"10021": "mac-thai",
"10029": "mac-ce",
"10079": "mac-icelandic",
"10081": "mac-turkish",
"10082": "mac-croatian",
// KOI8 codepages
"20866": "KOI8-R",
"21866": "KOI8-U",
// Miscellaneous
"708": "ISO-8859-6",
"16969": "UTF-64LE",
"20127": "ASCII"
};
var charset;
function getCodeName(codepage) {
// https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers
// https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings
if (codepage <= 500 || codepage >= 737 && codepage <= 870 || codepage > 1024 && codepage < 1200) {
// IBM codepages
return `IBM${codepage}`;
}
if (codepage > 1250 && codepage < 1300 || codepage === 874) {
// Windows codepages: 874, 1250-1258
return `Windows-${codepage}`;
}
if (codepage > 20270 && codepage < 20500 || codepage > 20870 && codepage < 20930) {
// IBM codepages
return `IBM${codepage - 20000}`;
}
if (codepage > 28590 && codepage < 29000) {
// ISO codepages: ISO-8859-1 - ISO-8859-16
return `ISO-8859-${codepage - 28590}`;
}
if (codepage >= 65000) {
// 65000 utf-7 Unicode (UTF-7)
// 65001 utf-8 Unicode (UTF-8)
return `UTF-${codepage - 64993}`;
}
codepage = String(codepage);
if (/^120+\d$/.test(codepage)) {
// 1200 UTF-16LE Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications
// 1201 UTF-16BE Unicode UTF-16, big endian byte order; available only to managed applications
// 12000 UTF-32LE Unicode UTF-32, little endian byte order; available only to managed applications
// 12001 UTF-32BE Unicode UTF-32, big endian byte order; available only to managed applications
return `UTF-${Math.pow(2, codepage.length)}${codepage.endsWith("0") ? "L" : "B"}E`;
}
return magic[codepage];
}
function getEncoding() {
if (!stdcp) {
stdcp = require("stdcp");
}
var codepage = stdcp.get();
return [getCodeName(codepage), String(codepage), codepage > 1000 && String(codepage % 1000)].find(isEncoding);
}
function fixEncoding(stdio, fromEncoding, toEncoding) {

@@ -133,4 +41,3 @@ if (Buffer.isBuffer(stdio)) {

var toEncoding = getEnvValue("LANG", options);
toEncoding = toEncoding && /\.[^.]+$/.exec(toEncoding);
toEncoding = toEncoding && toEncoding[0].slice(1);
toEncoding = toEncoding && toEncoding.replace(/^.*\./, "");

@@ -141,8 +48,22 @@ if (!isEncoding(toEncoding)) {

var fromEncoding = getEncoding();
if (!stdcp) {
stdcp = require("stdcp");
}
if (!fromEncoding || canonicalizeEncoding(fromEncoding) === canonicalizeEncoding(toEncoding)) {
if (!charset) {
charset = require("./charset.json");
}
var codepage = stdcp.getSync();
if (codepage === charset.codepage[canonicalizeEncoding(toEncoding)]) {
return;
}
var fromEncoding = charset.encoding[String(codepage)];
if (!isEncoding(fromEncoding)) {
return;
}
if (this.stdio) {

@@ -161,5 +82,5 @@ fixOutput(this, "stdio", fromEncoding, toEncoding);

// Canonicalize encoding name: strip all non-alphanumeric chars
return encoding.replace(/\W+/g, "").toUpperCase();
return encoding.replace(/[\W_]+/g, "").toLowerCase();
}
module.exports = stdio;
{
"name": "git-bash-shell",
"version": "2.3.0",
"version": "2.4.0",
"description": "Use Git Bash as cross-platform shell for Windows",

@@ -30,17 +30,19 @@ "keywords": [

"@babel/runtime": "^7.2.0",
"alias-win": "^1.0.0",
"fs-posix": "^6.0.0",
"git-win": "^2.2.5",
"git-win": "^2.3.0",
"iconv-lite": "^0.4.24",
"lru-cache": "^5.1.1",
"stdcp": "^1.0.0"
"stdcp": "^2.0.0"
},
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/preset-env": "^7.2.3",
"@babel/register": "^7.0.0",
"chai": "^4.2.0",
"codecov": "^3.1.0",
"eclint": "^2.8.1",
"eslint": "^5.10.0",
"eslint": "^5.11.0",
"eslint-config-standard": "^12.0.0",

@@ -51,3 +53,2 @@ "eslint-plugin-import": "^2.14.0",

"eslint-plugin-standard": "^4.0.0",
"expect.js": "^0.3.1",
"fs-extra": "^7.0.1",

@@ -66,3 +67,3 @@ "mocha": "^5.2.0",

"install": "node lib/install",
"build": "babel src --out-dir lib",
"build": "babel src --out-dir lib && cp src/*.json lib/",
"prepare": "npm run build",

@@ -69,0 +70,0 @@ "lint:eclint": "eclint check $(git ls-files | tee /tmp/git-files)",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc