Git Product home page Git Product logo

node-autostart's Introduction

Due to tight resources and serious issues with this project, I'm deprecating it. I highly recommend auto-launch, it has a similar API and should be easy to switch over to. Sorry for the circumstances.

node-autostart

Build Status Build status Coverage Status Dependency Status devDependency Status npm

node-autostart is a Node.js module that enables your module to activate autostart easily. You can also use it as a global module to set-up autostart for anything and anywhere via the command line interface (CLI). Currently, it supports:

  • Linux
  • OS X
  • Windows

Install:

npm install -g node-autostart

for use in CLI, and:

npm install --save node-autostart

as a dependency for your module.

Documentation

You can use node-autostart both programmatically and per CLI. 'Enabling autostart' means to make the OS run a certain command at logon of the user who 'enabled the autostart' via a program. The command could be, for example, npm start in a certain directory, or whatever floats your boat. Here's an example for use via the CLI:

  autostart enable -n "MyAwesomeApp" -p "/home/me/MyAwesomeApp" -c "npm start"

to enable,

  autostart check -n "MyAwesomeApp"

to see if it is enabled, and:

  autostart disable -n "MyAwesomeApp"

to disable it. To use it inside your Node.js app, look at the API for Programmatic Use, if you want to use it in the CLI, use autostart -h for further information.

API for Programmatic Use

First, require this module inside your app like this:

var autostart = require('node-autostart')

Now, you can simply enable autostart and disable it, and you can also check if it is enabled:

autostart.enableAutostart(key, command, path, function (err) {
  if(err) console.error(err);
})

autostart.disableAutostart(key, function (err) {
  if(err) console.error(err);
})

autostart.isAutostartEnabled(key, function (err, isEnabled) {
  if(err) console.error(err);

  if(isEnabled) {
    console.log('Autostart is enabled');
  }
  else {
    console.log('Autostart is not enabled');
  }

})

If you wish, you can also use Promises instead of Callbacks:

autostart.enableAutostart(key, command, path).then(() => {
  // Success!
}).catch((err) => {
  console.error(err);
  // Something bad happened
});

autostart.disableAutostart(key).then(() => {
  // Success!
}).catch((err) => {
  console.error(err);
  // Something bad happened
});

autostart.isAutostartEnabled(key).then((isEnabled) => {
  console.log('Autostart is ' + isEnabled ? 'enabled' : 'not enabled');
  // Success!
}).catch((err) => {
  console.error(err);
  // Something bad happened
});

Variables

key: Unique identifier for startup items (always required! (Make it unique))

command: Command to be executed in the specified path

path: Place in which the command will be executed (Use process.cwd() if you just want it to happen in your current working directory)

Functions

.enableAutostart Requires key, command and path, returns err.

.disableAutostart Requires key, returns err.

.isAutostartEnabled Requires key, returns err and isEnabled.

License

The MIT License (MIT)

Copyright (c) 2015 Max Rittmüller

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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.