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

@pkgr/utils

Package Overview
Dependencies
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pkgr/utils - npm Package Compare versions

Comparing version 2.3.1 to 2.4.0

2

lib/browser.d.ts

@@ -1,1 +0,1 @@

export declare function openBrowser(url: string): boolean;
export declare function openBrowser(url: string): Promise<boolean>;

@@ -0,1 +1,2 @@

import { __awaiter } from "tslib";
import { execSync } from 'node:child_process';

@@ -5,3 +6,2 @@ import path from 'node:path';

import spawn from 'cross-spawn';
import open from 'open';
import picocolors from 'picocolors';

@@ -51,65 +51,74 @@ const OSX_CHROME = 'google chrome';

function startBrowserProcess(browser, url, args) {
const shouldTryOpenChromiumWithAppleScript = process.platform === 'darwin' &&
(typeof browser !== 'string' || browser === OSX_CHROME);
if (shouldTryOpenChromiumWithAppleScript) {
const supportedChromiumBrowsers = [
'Google Chrome Canary',
'Google Chrome',
'Microsoft Edge',
'Brave Browser',
'Vivaldi',
'Chromium',
];
const _dirname = typeof __dirname === 'undefined'
? path.dirname(fileURLToPath(import.meta.url))
: __dirname;
for (const chromiumBrowser of supportedChromiumBrowsers) {
try {
execSync('ps cax | grep "' + chromiumBrowser + '"');
execSync('osascript ../openChrome.applescript "' +
encodeURI(url) +
'" "' +
chromiumBrowser +
'"', {
cwd: _dirname,
stdio: 'ignore',
});
return true;
return __awaiter(this, void 0, void 0, function* () {
const shouldTryOpenChromiumWithAppleScript = process.platform === 'darwin' &&
(typeof browser !== 'string' || browser === OSX_CHROME);
if (shouldTryOpenChromiumWithAppleScript) {
const supportedChromiumBrowsers = [
'Google Chrome Canary',
'Google Chrome',
'Microsoft Edge',
'Brave Browser',
'Vivaldi',
'Chromium',
];
const _dirname = typeof __dirname === 'undefined'
? path.dirname(fileURLToPath(import.meta.url))
: __dirname;
for (const chromiumBrowser of supportedChromiumBrowsers) {
try {
execSync('ps cax | grep "' + chromiumBrowser + '"');
execSync('osascript ../openChrome.applescript "' +
encodeURI(url) +
'" "' +
chromiumBrowser +
'"', {
cwd: _dirname,
stdio: 'ignore',
});
return true;
}
catch (_a) {
}
}
catch (_a) {
}
}
}
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined;
}
try {
open(url, {
app: browser
? {
name: browser,
arguments: args,
}
: undefined,
wait: false,
}).catch(() => { });
return true;
}
catch (_b) {
return false;
}
if (process.platform === 'darwin' && browser === 'open') {
browser = undefined;
}
try {
const open = (yield import('open')).default;
open(url, {
app: browser
? {
name: browser,
arguments: args,
}
: undefined,
wait: false,
}).catch(() => { });
return true;
}
catch (_b) {
return false;
}
});
}
export function openBrowser(url) {
const { action, value, args } = getBrowserEnv();
switch (action) {
case Action.NONE:
return false;
case Action.SCRIPT:
return executeNodeScript(value, url);
case Action.BROWSER:
return startBrowserProcess(value, url, args);
default:
throw new Error('Not implemented.');
}
return __awaiter(this, void 0, void 0, function* () {
const { action, value, args } = getBrowserEnv();
switch (action) {
case Action.NONE: {
return false;
}
case Action.SCRIPT: {
return executeNodeScript(value, url);
}
case Action.BROWSER: {
return startBrowserProcess(value, url, args);
}
default: {
throw new Error('Not implemented.');
}
}
});
}
//# sourceMappingURL=browser.js.map
/// <reference types="node" />
/// <reference types="webpack-env" />
export declare const DEV: "development";

@@ -4,0 +3,0 @@ export declare const PROD: "production";

@@ -48,5 +48,6 @@ import fs from 'node:fs';

...(isGlob(pkg)
? tryRequirePkg('tiny-glob/sync')(pkg, {
? tryRequirePkg('fast-glob').sync(pkg, {
absolute,
cwd: baseDir,
onlyFiles: false,
})

@@ -53,0 +54,0 @@ : [tryFile(path.resolve(baseDir, pkg), true)]),

{
"name": "@pkgr/utils",
"version": "2.3.1",
"version": "2.4.0",
"type": "module",

@@ -28,7 +28,7 @@ "description": "Shared utils for `@pkgr` packages or any package else",

"cross-spawn": "^7.0.3",
"fast-glob": "^3.2.12",
"is-glob": "^4.0.3",
"open": "^8.4.0",
"open": "^9.1.0",
"picocolors": "^1.0.0",
"tiny-glob": "^0.2.9",
"tslib": "^2.4.0"
"tslib": "^2.5.0"
},

@@ -35,0 +35,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

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