electron-lets-move

0.0.5 • Public • Published

npm version

Electron LetsMove

A module that offers to automatically move your Electron app to the Applications folder if opened from another location. Inspired by LetsMove for MacOS.

Electron LetsMove

Requirements

This module is designed to be used within Electron on macOS, it can be included in a cross platform Electron app and is a no-op on the Windows and Linux platforms.

Installation

npm install --save electron-lets-move

Usage

You should call the moveToApplications method as soon as possible after the app ready event in the main process. Ideally before the user has any chance to interact with the application.

moveToApplications returns a promise that will resolve when the application is in the correct location, the user asked not to move or an error occurred. You can also provide an optional node-style callback as the only parameter.

ES5

const {app} = require('electron');
const {moveToApplications} = require('electron-lets-move');
 
app.on('ready', function() {
  moveToApplications(function(err, moved) {
    if (err) {
      // log error, something went wrong whilst moving the app.
    }
    if (!moved) {
      // the user asked not to move the app, it's up to the parent application
      // to store this information and not hassle them again.
    }
 
    // do the rest of your application startup
  });
});

ES6

import {app} from 'electron';
import {moveToApplications} from 'electron-lets-move';
 
app.on('ready', async () => {
  try {
    const moved = await moveToApplications();
    if (!moved) {
      // the user asked not to move the app, it's up to the parent application
      // to store this information and not hassle them again.
    }
  } catch (err) {
    // log error, something went wrong whilst moving the app.
  }
 
  // do the rest of your application startup
});

License

Electron LetsMove is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with it. More Information

Readme

Keywords

none

Package Sidebar

Install

npm i electron-lets-move

Weekly Downloads

6

Version

0.0.5

License

MIT

Last publish

Collaborators

  • tommoor