New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

electron-util

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-util - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

45

index.js

@@ -73,1 +73,46 @@ 'use strict';

exports.fixPathForAsarUnpack = node.fixPathForAsarUnpack;
function isInApplicationsFolder() {
const exePath = api.app.getPath('exe');
const rootApplicationsPath = '/Applications';
const userApplicationsPath = path.join(api.app.getPath('home'), 'Applications');
return exePath.startsWith(rootApplicationsPath) || exePath.startsWith(userApplicationsPath);
}
function legacyEnforceMacOSAppLocation() {
if (!isInApplicationsFolder()) {
api.dialog.showErrorBox('Move to Applications folder', `Please move ${api.app.getName()} to your Applications folder to ensure it runs correctly.`);
api.app.quit();
}
}
exports.enforceMacOSAppLocation = () => {
if (is.development || !is.macos) {
return;
}
// Solution for pre-Electron 1.8.1 users
if (typeof api.app.isInApplicationsFolder !== 'function') {
return legacyEnforceMacOSAppLocation();
}
if (api.app.isInApplicationsFolder()) {
return;
}
const clickedButtonIndex = api.dialog.showMessageBox({
type: 'error',
message: 'Move to Applications folder?',
detail: `${api.app.getName()} must be live in the Applications folder to be able to run correctly.`,
buttons: ['Move to Applications folder', `Quit ${api.app.getName()}`],
defaultId: 0,
cancelId: 1
});
if (clickedButtonIndex === 1) {
api.app.quit();
return;
}
api.app.moveToApplicationsFolder();
};

2

package.json
{
"name": "electron-util",
"version": "0.4.1",
"version": "0.5.0",
"description": "Useful utilities for developing Electron apps and modules",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -145,3 +145,21 @@ # electron-util [![Build Status](https://travis-ci.org/sindresorhus/electron-util.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-util)

### enforceMacOSAppLocation()
Type: `Function`
On macOS, for [security reasons](https://github.com/potionfactory/LetsMove/issues/56), if an app is launched outside the Applications folder, it will run in a read-only disk image, which could cause subtle problems for your app. Use this method to ensure the app lives in the Applications folder.
It must not be used until the `app.on('ready')` event has been emitted.
It will be a noop during development and on other systems than macOS.
On Electron 1.8.1, it will offer to automatically move the app for the user:
<img src="https://user-images.githubusercontent.com/170270/34966593-3a0458c8-fa5d-11e7-805b-08bf80237e77.png" width="544">
On older Electron versions, it will just warn the user:
<img src="https://user-images.githubusercontent.com/170270/34966592-39e88dbe-fa5d-11e7-8597-397a98908600.png" width="532">
## Node.js API

@@ -148,0 +166,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