Socket
Socket
Sign inDemoInstall

shx

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shx - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

9

CHANGELOG.md

@@ -5,6 +5,13 @@ # Change Log

[Full Changelog](https://github.com/shelljs/shx/compare/v0.2.2...HEAD)
[Full Changelog](https://github.com/shelljs/shx/compare/v0.3.0...HEAD)
**Closed issues:**
- `shx echo -n aaa` shows `-n aaa` [\#129](https://github.com/shelljs/shx/issues/129)
## [v0.3.0](https://github.com/shelljs/shx/tree/v0.3.0) (2018-06-08)
[Full Changelog](https://github.com/shelljs/shx/compare/v0.2.2...v0.3.0)
**Closed issues:**
- Ship shx with shelljs@v0.8 [\#125](https://github.com/shelljs/shx/issues/125)

@@ -11,0 +18,0 @@ - Support executables [\#124](https://github.com/shelljs/shx/issues/124)

2

lib/config.js

@@ -46,3 +46,3 @@ 'use strict';

// If a non-boolean option is passed in, incrememnt the required argument
// If a non-boolean option is passed in, increment the required argument
// count (this is the case for `-n` for `head` and `tail`)

@@ -49,0 +49,0 @@ if (parsedArgs.n && (cmd === 'head' || cmd === 'tail')) {

@@ -45,4 +45,41 @@ #!/usr/bin/env node

var convertSedRegex = function convertSedRegex(args) {
var newArgs = [];
var lookingForSubstString = true;
args.forEach(function (arg) {
// A regex or replacement string can be any sequence of zero or more
// (a) non-slashes or (b) escaped chars.
var escapedChar = '\\\\.'; // This may match an escaped slash (i.e., "\/")
var nonSlash = '[^/]';
var nonSlashSequence = '(?:' + escapedChar + '|' + nonSlash + ')*';
var sedPattern = '^s/(' + nonSlashSequence + ')/(' + nonSlashSequence + ')/(g?)$';
var match = arg.match(new RegExp(sedPattern));
if (match && lookingForSubstString) {
var regexString = match[1].replace(/\\\//g, '/');
var replacement = match[2].replace(/\\\//g, '/').replace(/\\./g, '.');
var regexFlags = match[3];
if (regexString === '') {
// Unix sed gives an error if the pattern is the empty string, so we
// forbid this case even though JavaScript's .replace() has well-defined
// behavior.
throw new Error('Bad sed pattern (empty regex)');
}
newArgs.push(new RegExp(regexString, regexFlags));
newArgs.push(replacement);
lookingForSubstString = false;
} else {
newArgs.push(arg);
}
});
return newArgs;
};
function shx(argv) {
var parsedArgs = (0, _minimist2.default)(argv.slice(2), { stopEarly: true, boolean: true });
if (parsedArgs.version) {
var shxVersion = require('../package.json').version;
var shelljsVersion = require('shelljs/package.json').version;
console.log('shx v' + shxVersion + ' (using ShellJS v' + shelljsVersion + ')');
return _config.EXIT_CODES.SUCCESS;
}

@@ -95,20 +132,5 @@ var _parsedArgs$_ = _toArray(parsedArgs._),

// Workaround for sed syntax
var newArgs = void 0;
var ret = void 0;
if (fnName === 'sed') {
newArgs = [];
var lookingForSubstString = true;
args.forEach(function (arg) {
var match = arg.match(/^s\/((?:\\\/|[^\/])+)\/((?:\\\/|[^\/])*)\/(g?)$/);
if (match && lookingForSubstString) {
var regexString = match[1].replace(/\\\//g, '/');
var replacement = match[2].replace(/\\\//g, '/').replace(/\\./g, '.');
var regexFlags = match[3];
newArgs.push(new RegExp(regexString, regexFlags));
newArgs.push(replacement);
lookingForSubstString = false;
} else {
newArgs.push(arg);
}
});
var newArgs = convertSedRegex(args);
ret = _shelljs2.default[fnName].apply(input, newArgs);

@@ -136,2 +158,3 @@ } else {

} else if (_shelljs2.default.error()) {
/* istanbul ignore next */
return _config.EXIT_CODES.CMD_FAILED;

@@ -138,0 +161,0 @@ }

{
"name": "shx",
"version": "0.3.0",
"version": "0.3.1",
"description": "Portable Shell Commands for Node",

@@ -55,5 +55,5 @@ "bin": {

"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.7.2",
"codecov": "^1.0.1",
"codecov": "^3.0.2",
"concurrently": "^2.1.0",

@@ -63,4 +63,4 @@ "eslint": "^2.10.1",

"eslint-plugin-import": "^1.8.0",
"mocha": "^2.4.5",
"nyc": "^6.4.0",
"mocha": "^5.2.0",
"nyc": "^12.0.2",
"rimraf": "^2.5.2",

@@ -67,0 +67,0 @@ "shelljs-changelog": "^0.2.0",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc