Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

better-opn

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-opn - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

16

CHANGELOG.md

@@ -10,2 +10,13 @@ # Changelog

## [2.0.0] - 2020-04-06
### Added
- Support for chromium browsers, see [facebook/create-react-app#8367](https://github.com/facebook/create-react-app/pull/8367) for more detail (#5) @yannbf
### Changed
- Upgrade `open` from `v6.4.0` to `v7.0.3`, see [breaking change](https://github.com/sindresorhus/open/releases/tag/v7.0.0) for more detail and it has been properly addressed in this [commit](https://github.com/ExiaSR/better-opn/commit/009601f6282106313abcae047e5cd0c3afcf778e#diff-1fdf421c05c1140f6d71444ea2b27638R80).
- Upgrade `babel` to latest release
## [1.0.0] - 2019-09-06

@@ -18,4 +29,5 @@

[unreleased]: https://github.com/ExiaSR/better-opn/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/ExiaSR/better-opn/compare/v1.0.0...v0.1.4
[unreleased]: https://github.com/ExiaSR/better-opn/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/ExiaSR/better-opn/compare/v1.0.0...v2.0.0
[1.0.0]: https://github.com/ExiaSR/better-opn/compare/v0.1.4...v1.0.0
[0.1.4]: https://github.com/ExiaSR/better-opn/compare/v0.1.4

58

dist/index.js

@@ -5,3 +5,3 @@ "use strict";

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

@@ -23,4 +23,5 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// It is specific to the operating system.
// See https://github.com/sindresorhus/opn#app for documentation.
// See https://github.com/sindresorhus/open#app for documentation.
var value = process.env.BROWSER;
var args = process.env.BROWSER_ARGS ? process.env.BROWSER_ARGS.split(' ') : [];
var action;

@@ -39,6 +40,8 @@

action,
value
value,
args
};
}; // Copy from
// https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js#L64
// eslint-disable-next-line unicorn/prevent-abbreviations

@@ -48,2 +51,3 @@

var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
// If we're on OS X, the user hasn't specifically

@@ -53,16 +57,21 @@ // requested a different browser, we can try opening

// existing tab when possible instead of creating a new one.
var shouldTryOpenChromeWithAppleScript = process.platform === 'darwin' && (typeof browser !== 'string' || browser === OSX_CHROME);
var shouldTryOpenChromiumWithAppleScript = process.platform === 'darwin' && (typeof browser !== 'string' || browser === OSX_CHROME);
if (shouldTryOpenChromeWithAppleScript) {
try {
// Try our best to reuse existing tab
// on OS X Google Chrome with AppleScript
execSync('ps cax | grep "Google Chrome"');
execSync("osascript ../openChrome.applescript \"".concat(encodeURI(url), "\""), {
cwd: __dirname,
stdio: 'ignore'
});
return Promise.resolve(true);
} catch (err) {// Ignore errors.
// It it breaks, it will fallback to `opn` anyway
if (shouldTryOpenChromiumWithAppleScript) {
// Will use the first open browser found from list
var supportedChromiumBrowsers = ['Google Chrome Canary', 'Google Chrome', 'Microsoft Edge', 'Brave Browser', 'Vivaldi', 'Chromium'];
for (var chromiumBrowser of supportedChromiumBrowsers) {
try {
// Try our best to reuse existing tab
// on OSX Chromium-based browser with AppleScript
execSync('ps cax | grep "' + chromiumBrowser + '"');
execSync("osascript ../openChrome.applescript \"".concat(encodeURI(url), "\" \"").concat(chromiumBrowser, "\""), {
cwd: __dirname,
stdio: 'ignore'
});
return Promise.resolve(true); // eslint-disable-next-line no-unused-vars
} catch (error) {// Ignore errors.
// It it breaks, it will fallback to `opn` anyway
}
}

@@ -77,2 +86,7 @@ } // Another special case: on OS X, check if BROWSER has been set to "open".

browser = undefined;
} // If there are arguments, they must be passed as array with the browser
if (typeof browser === 'string' && args.length > 0) {
browser = [browser].concat(args);
} // Fallback to opn

@@ -83,13 +97,15 @@ // (It will always open new tab)

var options = _objectSpread({
app: browser
app: browser,
url: true,
wait: false
}, opts);
console.debug(options);
return require('open')(url, options);
};
module.exports = (target, opts) => {
module.exports = (target, options) => {
var {
action,
value
value,
args
} = getBrowserEnv();

@@ -103,3 +119,3 @@

case Actions.BROWSER:
return startBrowserProcess(value, target, opts);
return startBrowserProcess(value, target, options, args);

@@ -106,0 +122,0 @@ default:

{
"name": "better-opn",
"version": "1.0.0",
"version": "2.0.0",
"description": "A better opn. Reuse the same tab on Chrome for 👨‍💻.",

@@ -30,19 +30,23 @@ "main": "dist/index.js",

],
"xo": {
"_nodeVersion": "falling back to --node-version cli argument since this is not working",
"nodeVersion": ">=10.0.0",
"space": 2,
"prettier": true,
"envs": ["node"]
},
"scripts": {
"build": "babel src -d dist",
"lint": "eslint src --fix",
"format": "prettier --write \"src/**/*.js\""
"_lint": "--node-version is a work around since we use v8 as target in babel anyway",
"lint": "xo src/ --fix --node-version \">=10.0.0\""
},
"dependencies": {
"open": "^6.4.0"
"open": "^7.0.3"
},
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"eslint": "^5.10.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-prettier": "^3.0.0",
"prettier": "^1.13.7"
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"xo": "^0.28.3"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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