Giter Club home page Giter Club logo

electron-lets-move's Introduction

This functionality is now baked into Electron and the project is archived. I suggest using the new native API.

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

electron-lets-move's People

Contributors

tommoor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.