Socket
Socket
Sign inDemoInstall

@react-native-community/cli-tools

Package Overview
Dependencies
Maintainers
39
Versions
163
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/cli-tools - npm Package Compare versions

Comparing version 4.10.1 to 4.11.0

14

build/launchDebugger.js

@@ -67,4 +67,16 @@ "use strict";

case 'win32':
return 'chrome';
{
const possibleDebuggingApps = ['chrome.exe', 'msedge.exe'];
const output = (0, _child_process().execSync)('tasklist /NH /FO CSV /FI "SESSIONNAME ne Services"').toString();
const runningProcesses = output.split('\n').map(line => line.replace(/^"|".*\r$/gm, ''));
for (const app of possibleDebuggingApps) {
if (runningProcesses.includes(app)) {
return app;
}
}
return 'chrome';
}
case 'linux':

@@ -71,0 +83,0 @@ if (commandExistsUnixSync('google-chrome')) {

@@ -94,2 +94,10 @@ "use strict";

'/Applications/WebStorm.app/Contents/MacOS/webstorm': 'webstorm'
}; // Map of process image name used to identify already running instances of the editor
// And an editor id which is used to determine which arguments to add to the commandline
const COMMON_WINDOWS_EDITORS = {
'Code.exe': 'code',
'sublime_text.exe': 'subl',
'devenv.exe': 'devenv',
'notepad.exe': 'notepad'
}; // Transpiled version of: /^([a-zA-Z]+:)?[\p{L}0-9/.\-_\\]+$/u

@@ -139,2 +147,5 @@ // Non-transpiled version requires support for Unicode property regex. Allows

return addWorkspaceToArgumentsIfExists(['-g', `${fileName}:${lineNumber}`], workspace);
case 'devenv':
return ['/EDIT', fileName];
// For all others, drop the lineNumber until we have

@@ -149,2 +160,16 @@ // a mapping above, since providing the lineNumber incorrectly

function getArgumentsForFileName(editor, fileName, workspace) {
switch (_path().default.basename(editor)) {
case 'code':
return addWorkspaceToArgumentsIfExists([fileName], workspace);
case 'devenv':
return ['/EDIT', fileName];
// Every other editor just takes the filename as an argument
default:
return [fileName];
}
}
function guessEditor() {

@@ -154,14 +179,12 @@ // Explicit config always wins

return _shellQuote().default.parse(process.env.REACT_EDITOR);
} // Using `ps x` on OSX we can find out which editor is currently running.
// Potentially we could use similar technique for Windows and Linux
}
if (process.platform === 'darwin') {
try {
try {
// Using `ps x` on OSX we can find out which editor is currently running.
// Potentially we could use similar technique for Linux
if (process.platform === 'darwin') {
const output = (0, _child_process().execSync)('ps x').toString();
const processNames = Object.keys(COMMON_EDITORS);
for (let i = 0; i < processNames.length; i++) {
const processName = processNames[i];
for (const processName of processNames) {
if (output.indexOf(processName) !== -1) {

@@ -171,5 +194,15 @@ return [COMMON_EDITORS[processName]];

}
} catch (error) {// Ignore...
} else if (process.platform === 'win32') {
const output = (0, _child_process().execSync)('tasklist /NH /FO CSV /FI "SESSIONNAME ne Services"').toString();
const runningProcesses = output.split('\n').map(line => line.replace(/^"|".*\r$/gm, ''));
const processNames = Object.keys(COMMON_WINDOWS_EDITORS);
for (const processName of processNames) {
if (runningProcesses.includes(processName)) {
return [COMMON_WINDOWS_EDITORS[processName]];
}
}
}
} // Last resort, use old skool env vars
} catch (error) {} // Ignore...
// Last resort, use old skool env vars

@@ -189,3 +222,6 @@

function printInstructions(title) {
_logger.default.info(['', _chalk().default.bgBlue.white.bold(` ${title} `), ' When you see Red Box with stack trace, you can click any ', ' stack frame to jump to the source file. The packager will launch your ', ' editor of choice. It will first look at REACT_EDITOR environment ', ' variable, then at EDITOR. To set it up, you can add something like ', ' export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on ', ' which shell you use.', ''].join('\n'));
const WINDOWS_FIXIT_INSTRUCTIONS = [' To set it up, you can run something like "SETX REACT_EDITOR code"', ' which will set the environment variable in future shells,', ' then "SET REACTEDITOR=code" to set it in the current shell'];
const FIXIT_INSTRUCTIONS = [' To set it up, you can add something like ', ' export REACT_EDITOR=atom to your ~/.bashrc or ~/.zshrc depending on ', ' which shell you use.'];
_logger.default.info(['', _chalk().default.bgBlue.white.bold(` ${title} `), ' When you see Red Box with stack trace, you can click any ', ' stack frame to jump to the source file. The packager will launch your ', ' editor of choice. It will first look at REACT_EDITOR environment ', ' variable, then at EDITOR.', ...(process.platform === 'win32' ? WINDOWS_FIXIT_INSTRUCTIONS : FIXIT_INSTRUCTIONS), ''].join('\n'));
}

@@ -207,2 +243,48 @@

});
} // On windows, find the editor executable path even if its not in the users path
function editorWindowsLaunchPath(editor) {
if (_fs().default.existsSync(editor)) {
// Editor is a full path to an exe, we can just launch it
return editor;
}
try {
(0, _child_process().execSync)(`where ${editor}`, {
stdio: 'ignore'
}); // Editor is on the path, we can just launch it
return editor;
} catch (error) {// ignore
}
try {
const editorNames = Object.values(COMMON_WINDOWS_EDITORS);
const editorImageNames = Object.keys(COMMON_WINDOWS_EDITORS);
for (let i = 0; i < editorNames.length; i++) {
const editorName = editorNames[i];
if (editor.toLowerCase() === editorName.toLowerCase()) {
// An editor was guessed by guessEditor, but isn't part of the users path
// Attempt to get the executable location from the running process
const output = (0, _child_process().execSync)(`tasklist /FO CSV /NH /FI "IMAGENAME eq ${editorImageNames[i]}"`).toString();
const results = output.split(',');
if (results[0] !== `"${editorImageNames[i]}"`) {
// Failed to find a running instance...
return editor;
}
const pid = parseInt(results[1].replace(/^"|"$/gm, ''), 10);
return (0, _child_process().execSync)(`powershell (Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").ExecutablePath`).toString().trim();
}
}
} catch (error) {} // ignore
// Just use what the user specified, it will probably fail,
// but we will show some help text when it fails.
return editor;
}

@@ -235,3 +317,3 @@

} else {
args.push(fileName);
args = args.concat(getArgumentsForFileName(editor, fileName, workspace));
} // cmd.exe on Windows is vulnerable to RCE attacks given a file name of the

@@ -263,3 +345,3 @@ // form "C:\Users\myusername\Downloads\& curl 172.21.93.52". Use a whitelist

// launch .exe files.
_childProcess = (0, _child_process().spawn)('cmd.exe', ['/C', editor].concat(args), {
_childProcess = (0, _child_process().spawn)('cmd.exe', ['/C', editorWindowsLaunchPath(editor)].concat(args), {
stdio: 'inherit'

@@ -266,0 +348,0 @@ });

4

package.json
{
"name": "@react-native-community/cli-tools",
"version": "4.10.1",
"version": "4.11.0",
"license": "MIT",

@@ -27,3 +27,3 @@ "main": "build/index.js",

],
"gitHead": "f76add94dcfb647dd55b59a5fad9a4d5363962fa"
"gitHead": "a94c0446ad2a1ab68c040dd51cd9eec6a0605993"
}
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