How to use the electron-util/node.fixPathForAsarUnpack function in electron-util

To help you get started, we’ve selected a few electron-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sallar / node-mac-app-icon / index.js View on Github external
const path = require('path');
const execa = require('execa');
const electronUtil = require('electron-util/node');

// Workaround for https://github.com/electron/electron/issues/9459
const execPath = path.join(electronUtil.fixPathForAsarUnpack(__dirname), 'run');

/**
 * @typedef {Object} Options
 * @property {number} size Size of output icon (in points)
 */

/**
 * @typedef {Object} ListOptions
 * @property {number} size Size of output icon (in points)
 * @property {boolean} failOnError Fail hard if a pid in the list was not found
 */

/**
 * @typedef {Object} ListResult
 * @property {number} pid PID of the application
 * @property {Buffer} icon Buffer containing image data
github karaggeorge / mac-screen-capture-permissions / index.js View on Github external
'use strict';
const path = require('path');
const fs = require('fs');
const execa = require('execa');
const {isElectron, fixPathForAsarUnpack} = require('electron-util/node');
const macosVersion = require('macos-version');

const binary = path.join(fixPathForAsarUnpack(__dirname), 'screen-capture-permissions');

const permissionExists = macosVersion.isGreaterThanOrEqualTo('10.15');

let filePath;

if (isElectron) {
	const {api, openSystemPreferences} = require('electron-util');

	exports.openSystemPreferences = () => openSystemPreferences('security', 'Privacy_ScreenCapture');

	filePath = api.app && path.join(api.app.getPath('userData'), '.has-app-requested-screen-capture-permissions');
}

exports.hasScreenCapturePermission = () => {
	if (!permissionExists) {
		return true;