auto-launch
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -12,2 +12,3 @@ var AutoLaunch, | ||
this.fixOpts = __bind(this.fixOpts, this); | ||
var versions; | ||
if (opts.name == null) { | ||
@@ -19,3 +20,10 @@ throw new Error('You must specify a name'); | ||
this.opts.isHiddenOnLaunch = opts.isHidden != null ? opts.isHidden : false; | ||
this.opts.appPath = opts.path != null ? opts.path : process.execPath; | ||
versions = typeof process !== "undefined" && process !== null ? process.versions : void 0; | ||
if (opts.path != null) { | ||
this.opts.appPath = opts.path; | ||
} else if ((versions != null) && ((versions.nwjs != null) || (versions['node-webkit'] != null) || (versions.electron != null))) { | ||
this.opts.appPath = process.execPath; | ||
} else { | ||
throw new Error("You must give a path (this is only auto-detected for NW.js and Electron apps)"); | ||
} | ||
this.fixOpts(); | ||
@@ -32,12 +40,4 @@ this.api = null; | ||
AutoLaunch.prototype.fixNwExecPath = function(path) { | ||
var possible, possiblePaths, _i, _len; | ||
possiblePaths = [path.replace('/Contents/Frameworks/node-webkit Helper.app/Contents/MacOS/node-webkit Helper', ''), path.replace('/Contents/Frameworks/nwjs Helper.app/Contents/MacOS/nwjs Helper', '')]; | ||
for (_i = 0, _len = possiblePaths.length; _i < _len; _i++) { | ||
possible = possiblePaths[_i]; | ||
if (possible !== process.execPath) { | ||
return possible; | ||
} | ||
} | ||
return path; | ||
AutoLaunch.prototype.fixMacExecPath = function(path) { | ||
return path.replace(/(^.+?[^\/]+?\.app)\/Contents\/(Frameworks\/((\1|[^\/]+?) Helper)\.app\/Contents\/MacOS\/\3|MacOS\/Electron)/, '$1'); | ||
}; | ||
@@ -57,3 +57,3 @@ | ||
if (/darwin/.test(process.platform)) { | ||
this.opts.appPath = this.fixNwExecPath(this.opts.appPath); | ||
this.opts.appPath = this.fixMacExecPath(this.opts.appPath); | ||
} | ||
@@ -60,0 +60,0 @@ if (this.opts.appPath.indexOf('/') !== -1) { |
{ | ||
"name": "auto-launch", | ||
"version": "1.0.2", | ||
"description": "Launch node-webkit apps at login (mac & windows)", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/4ver/node-auto-launch" | ||
}, | ||
"keywords": [ | ||
"login", | ||
"launch", | ||
"node-webkit", | ||
"boot", | ||
"login-items" | ||
], | ||
"author": "Donal Linehan", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/4ver/node-auto-launch/issues" | ||
}, | ||
"devDependencies": { | ||
"gulp": ">=3.8.2", | ||
"gulp-coffee": "2.0.1", | ||
"coffee-script": "~1.7.1", | ||
"gulp-mocha": "~0.4.1", | ||
"chai": "~1.9.1", | ||
"gulp-util": "~2.2.18", | ||
"gulp-load-plugins": "~0.5.2", | ||
"gulp-coffeelint": "~0.3.3", | ||
"teamwork-coffeelint-rules": "0.0.1", | ||
"gulp-coffeelint-threshold": "^1.0.0" | ||
}, | ||
"homepage": "https://github.com/4ver/node-auto-launch", | ||
"dependencies": { | ||
"applescript": "^0.2.1", | ||
"winreg": "0.0.12", | ||
"mkdirp": "0.5.1", | ||
"untildify": "2.1.0" | ||
} | ||
"name": "auto-launch", | ||
"version": "1.1.0", | ||
"description": "Launch node-webkit apps at login (mac & windows)", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "gulp test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/4ver/node-auto-launch" | ||
}, | ||
"keywords": [ | ||
"login", | ||
"launch", | ||
"node-webkit", | ||
"boot", | ||
"login-items" | ||
], | ||
"author": "Donal Linehan", | ||
"contributors": [ | ||
"Adam Lynch <adam@teamwork.com>" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/4ver/node-auto-launch/issues" | ||
}, | ||
"devDependencies": { | ||
"gulp": ">=3.8.2", | ||
"gulp-coffee": "2.0.1", | ||
"coffee-script": "~1.7.1", | ||
"gulp-mocha": "~0.4.1", | ||
"chai": "~1.9.1", | ||
"gulp-util": "~2.2.18", | ||
"gulp-load-plugins": "~0.5.2", | ||
"gulp-coffeelint": "~0.3.3", | ||
"teamwork-coffeelint-rules": "0.0.1", | ||
"gulp-coffeelint-threshold": "^1.0.0" | ||
}, | ||
"homepage": "https://github.com/4ver/node-auto-launch", | ||
"dependencies": { | ||
"applescript": "^0.2.1", | ||
"winreg": "0.0.12", | ||
"mkdirp": "0.5.1", | ||
"untildify": "2.1.0" | ||
} | ||
} |
@@ -8,3 +8,3 @@ node-auto-launch | ||
Launch node-webkit apps at login (Mac, Windows and Linux) | ||
Launch applications or executables at login (Mac, Windows and Linux). Perfect for [NW.js](https://github.com/nwjs/nw.js) and [Electron](http://electron.atom.io/) apps. | ||
@@ -15,21 +15,32 @@ ## Installation | ||
## General | ||
## Usage | ||
So far the api consists only `enable` `disable` and `isEnabled`. | ||
The API consists only of `enable`, `disable`, and `isEnabled`. | ||
## Usage | ||
```javascript | ||
var AutoLaunch = require('auto-launch'); | ||
For node-webkit apps you don't have to specify the path. It gets read from `process.execPath` :) | ||
var minecraftAutoLauncher = new AutoLaunch({ | ||
name: 'Minecraft', | ||
path: '/Applications/Minecraft.app', | ||
isHidden: true // hidden on launch - only works on a mac atm. | ||
}); | ||
minecraftAutoLauncher.enable(); | ||
//minecraftAutoLauncher.disable(); | ||
``` | ||
For NW.js or Electron apps you don't have to specify the path. It gets read from `process.execPath` :) | ||
```javascript | ||
var AutoLaunch = require('auto-launch'); | ||
var nwAppLauncher = new AutoLaunch({ | ||
name: 'My node webkit app yao' | ||
var appLauncher = new AutoLaunch({ | ||
name: 'My NW.js or Electron app' | ||
}); | ||
nwAppLauncher.isEnabled(function(enabled){ | ||
appLauncher.isEnabled(function(enabled){ | ||
if(enabled) return; | ||
nwAppLauncher.enable(function(err){ | ||
appLauncher.enable(function(err){ | ||
@@ -41,22 +52,8 @@ }); | ||
I added a method (`removeNwjsLoginItem`) to remove 'nwjs helper' app login item that might have been added to peoples accounts since the name change from node-webkit. | ||
Note: I added a method (`removeNwjsLoginItem`) to remove 'nwjs helper' app login item that might have been added to peoples accounts since the name change from node-webkit to NW.js. | ||
For general apps | ||
```javascript | ||
var AutoLaunch = require('auto-launch'); | ||
var minecraftAutoLauncher = new AutoLaunch({ | ||
name: 'Minecraft', | ||
path: '/Applications/Minecraft.app', | ||
isHidden: true // hidden on launch - only works on a mac atm. | ||
}); | ||
minecraftAutoLauncher.enable(); | ||
//minecraftAutoLauncher.disable(); | ||
``` | ||
## TODO: | ||
- Add `getCurrentPath` - So you can check if the app has moved a roundabout. | ||
- Add `getCurrentPath` - So you can check if the app has moved around. | ||
@@ -74,2 +71,2 @@ | ||
[depstat-url]: https://david-dm.org/teamwork/auto-launch | ||
[depstat-image]: https://david-dm.org/teamwork/auto-launch.svg?style=flat | ||
[depstat-image]: https://david-dm.org/teamwork/auto-launch.svg?style=flat |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9555
68