This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+4
View File
@@ -0,0 +1,4 @@
example/
test
*.md
node-notifier_flow.png
+10
View File
@@ -0,0 +1,10 @@
os:
- linux
- osx
language: node_js
node_js:
- "6"
- "5"
- "4"
- "0.11"
- "0.10"
+159
View File
@@ -0,0 +1,159 @@
Changelog
===
### `v4.6.1`
1. Adds npm ignore file, ignoring tests and examples from package.
2. Fixes CI builds
### `v4.6.0`
1. Adds support for Icon URL in Growl ([by @gucong3000](https://github.com/mikaelbr/node-notifier/pull/115))
2. Adds options for passing host and port to cli tool ([reported by @el-davo](https://github.com/mikaelbr/node-notifier/issues/106))
3. Fixes sanitize response on `notify` callback ([by @MadLittleMods](https://github.com/mikaelbr/node-notifier/commit/a44454a11eff452a8b55f9fbe291e189ed088708))
4. Fixes use of new line in messages ([by @gucong3000](https://github.com/mikaelbr/node-notifier/pull/115))
5. Fixes use of `file:///xxx` protocol icon paths for Windows 8.1 ([by @gucong3000](https://github.com/mikaelbr/node-notifier/pull/118))
6. Fixes non-TTY usage and piping messages ([reported by @simensen](https://github.com/mikaelbr/node-notifier/issues/109))
7. Updates vendor terminal-notifier version to 1.6.3 ([reported by @kid-icarus](https://github.com/mikaelbr/node-notifier/pull/120))
### `v4.5.0`
#### Additions
1. Adds syntactic sugar for `notify`. Now able to just pass message:
```js
notifier.notify('My message');
```
See [#45](https://github.com/mikaelbr/node-notifier/issues/45) for more info.
#### Fixes
1. Improvements to docs and examples
2. Updates `semver` dependency to support Webpacking with Electron.
### `v4.4.0`
1. Changes to exec terminal-notifier through execFile to allow for asar-packages
2. Adds support for remote growl server
3. Adds support for win7 with electron asar-package
### `v4.3.1`
Obligatory patch fix:
1. Adds new stdin CLI options to docs
### `v4.3.0`
1. Adds support for piping messages in to CLI.
(With `node-notifier` installed as a CLI `npm i -g node-notifier`)
```shell
echo "Message" | notify
echo "Message" | notify -t "My Title"
echo "Some message" | notify -t "My Title" -s
```
### `v4.2.3`
1. Fixed input arguments to CLI to be strings where they should be strings.
### `v4.2.2`
1. Fixed no notification when no message for the CLI. [#58](https://github.com/mikaelbr/node-notifier/pull/58)
2. Changes `which` test to be sync, avoiding some edge cases with multiple notifications.
### `v4.2.1`
1. Minor fix for docs in CLI usage
### `v4.2.0`
1. Adds CLI support.
2. Fixes Debug "HRESULT : 0xC00CE508" exception on Win8. PR [#49](https://github.com/mikaelbr/node-notifier/pull/49)
### `v4.1.2`
1. Fixes correct terminal-notifier (own fork https://github.com/mikaelbr/terminal-notifier)
to support activate / click.
### `v4.1.1`
1. Fixes proper error codes for balloon: #42
2. Removes unused debug files: #41
3. Patches differences between subtitle for notify-send: #43
4. Updates terminal-notifier dependency (removing black borders) #44 #18
### `v4.1.0`
1. Adds support for changing host and port for Growl.
### `v4.0.3`
1. Fixes Notification center issue with multiple callback events.
2. Fixes error in source code: Fixes long-spaces to proper spaces
### `v4.0.2`
1. Fixes issue with immidiate notifu notifications (with `wait : false`)
2. Fixes issue with boolean flags for notifu.
3. Restructures directories. Making it easier to require notifiers directly.
### `v4.0.1`
1. Fixes issue with optional callback for notify-send
### `v4.0.0`
Major changes and breaking API.
1. require('node-notifier') now returns an instance with fallbackable notifications.
```js
var notifier = require('node-notifier');
notifier.notify();
```
2. Introduced a `wait` property (default `false`), to get user input for
Notification Center, Windows Toaster, Windows Balloons and Growl. Sadly not
for notify-send.
```js
var notifier = require('node-notifier');
notifier.notify({ wait: true }, function (err, response) {
// response is response after user have interacted
// with the notification or the notification has timed out.
});
```
3. All notification instances are now event emitters, emitting events
`click` or `timeout`. This is only applicable if `{ wait: true }`.
```js
var notifier = require('node-notifier');
notifier.on('click', function (notificationObject, options) {
// options.someArbitraryData === 'foo'
});
notifier.notify({ wait: true, someArbitraryData: 'foo' });
```
4. WindowsToaster and NotificationCenter now can have sounds by doing `{ sound: true }`.
Default NotificationCenter sound is Bottle. Can still use define sound on
Mac:
```js
var notifier = require('node-notifier');
notifier.notify({ sound: true });
// For mac (same as sound: true on Windows 8)
notifier.notify({ sound: 'Morse' });
```
### `v3.4.0`
1. Adds Growl as priority over Balloons
### `v3.3.0`
1. Adds support for native Windows 7 and earlier (through task bar balloons)
2. Changes growl implementation. Adds better support for GNTP
### `v3.2.1`
1. Fixes support for notifications from folders with spaces on Windows.
### `v3.2.0`
1. Adds native Windows 8 support.
### `v3.1.0`
1. Adds Growl as fallback for Mac OS X pre 10.8.
### `v3.0.6`
1. Fixes typo: Changes Growl app name from `Gulp` to `Node`.
### `v3.0.5`
1. Maps common options between the different notifiers. Allowing for common usage with different notifiers.
### `v3.0.4`
1. Fixes expires for notify-send (Issue #13)
### `v3.0.2`
1. Fixes version check for Mac OS X Yosemite
### `v3.0.0`
1. Updates terminal-notifier to version 1.6.0; adding support for appIcon and contentImage
2. Removes parsing of output sent from notifier (Notification Center)
+368
View File
@@ -0,0 +1,368 @@
# node-notifier [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][depstat-image]][depstat-url]
A Node.js module for sending cross platform system notifications. Using
Notification Center for Mac, notify-osd/libnotify-bin for Linux, Toasters for
Windows 8/10, or taskbar Balloons for earlier Windows versions. If none of
these requirements are met, Growl is used.
![Mac Screenshot](https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/mac.png)
![Native Windows Screenshot](https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/windows.png)
![Growl Screenshot](https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/growl.png)
## Quick Usage
Show a native notification on Mac, Windows, Linux:
```javascript
const notifier = require('node-notifier');
// String
notifier.notify('Message');
// Object
notifier.notify({
'title': 'My notification',
'message': 'Hello, there!'
});
```
## Requirements
- **Mac OS X**: >= 10.8 or Growl if earlier.
- **Linux**: `notify-osd` or `libnotify-bin` installed (Ubuntu should have this by default)
- **Windows**: >= 8, task bar balloon if earlier or Growl if that is installed.
- **General Fallback**: Growl
Growl takes precedence over Windows balloons.
See [documentation and flow chart for reporter choice](./DECISION_FLOW.md)
## Install
```
$ npm install --save node-notifier
```
## Cross-Platform Advanced Usage
Standard usage, with cross-platform fallbacks as defined in the
[reporter flow chart](./DECISION_FLOW.md). All of the options
below will work in a way or another on all platforms.
```javascript
const notifier = require('node-notifier');
const path = require('path');
notifier.notify({
title: 'My awesome title',
message: 'Hello from node, Mr. User!',
icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
}, function (err, response) {
// Response is response from notification
});
notifier.on('click', function (notifierObject, options) {
// Triggers if `wait: true` and user clicks notification
});
notifier.on('timeout', function (notifierObject, options) {
// Triggers if `wait: true` and notification closes
});
```
You can also specify what reporter you want to use if you
want to customize it or have more specific options per system.
See documentation for each reporter below.
Example:
```javascript
const NotificationCenter = require('node-notifier/notifiers/notificationcenter');
new NotificationCenter(options).notify();
const NotifySend = require('node-notifier/notifiers/notifysend');
new NotifySend(options).notify();
const WindowsToaster = require('node-notifier/notifiers/toaster');
new WindowsToaster(options).notify();
const Growl = require('node-notifier/notifiers/growl');
new Growl(options).notify();
const WindowsBalloon = require('node-notifier/notifiers/balloon');
new WindowsBalloon(options).notify();
```
Or if you are using several (or you are lazy):
(note: technically, this takes longer to require)
```javascript
const nn = require('node-notifier');
new nn.NotificationCenter(options).notify();
new nn.NotifySend(options).notify();
new nn.WindowsToaster(options).notify(options);
new nn.WindowsBalloon(options).notify(options);
new nn.Growl(options).notify(options);
```
## Contents
* [Notification Center documentation](#usage-notificationcenter)
* [Windows Toaster documentation](#usage-windowstoaster)
* [Windows Balloon documentation](#usage-windowsballoon)
* [Growl documentation](#usage-growl)
* [Notify-send documentation](#usage-notifysend)
### Usage NotificationCenter
Same usage and parameter setup as [terminal-notifier](https://github.com/alloy/terminal-notifier).
Native Notification Center requires Mac OS X version 10.8 or higher. If you have
an earlier version, Growl will be the fallback. If Growl isn't installed, an
error will be returned in the callback.
#### Example
Wrapping around [terminal-notifier](https://github.com/alloy/terminal-notifier), you can
do all terminal-notifier can do through properties to the `notify` method. E.g.
if `terminal-notifier` says `-message`, you can do `{message: 'Foo'}`, or
if `terminal-notifier` says `-list ALL`, you can do `{list: 'ALL'}`. Notification
is the primary focus for this module, so listing and activating do work,
but isn't documented.
### All notification options with their defaults:
```javascript
const NotificationCenter = require('node-notifier').NotificationCenter;
var notifier = new NotificationCenter({
withFallback: false, // Use Growl Fallback if <= 10.8
customPath: void 0 // Relative path if you want to use your fork of terminal-notifier
});
notifier.notify({
'title': void 0,
'subtitle': void 0,
'message': void 0,
'sound': false, // Case Sensitive string for location of sound file, or use one of OS X's native sounds (see below)
'icon': 'Terminal Icon', // Absolute Path to Triggering Icon
'contentImage': void 0, // Absolute Path to Attached Image (Content Image)
'open': void 0, // URL to open on Click
'wait': false // Wait for User Action against Notification
}, function(error, response) {
console.log(response);
});
```
**For Mac OS notifications, icon and contentImage requires OS X 10.9.**
Sound can be one of these: `Basso`, `Blow`, `Bottle`, `Frog`, `Funk`, `Glass`,
`Hero`, `Morse`, `Ping`, `Pop`, `Purr`, `Sosumi`, `Submarine`, `Tink`.
If sound is simply `true`, `Bottle` is used.
See [specific Notification Center example](./example/advanced.js).
### Usage WindowsToaster
**Note:** There are some limitations for images in native Windows 8 notifications:
The image must be a PNG image, and cannot be over 1024x1024 px, or over over 200Kb.
You also need to specify the image by using an absolute path. These limitations are
due to the Toast notification system. A good tip is to use something like
`path.join` or `path.delimiter` to have cross-platform pathing.
**Windows 10 Note:** You might have to activate banner notification for the toast to show.
From [mikaelbr/gulp-notify#90 (comment)](https://github.com/mikaelbr/gulp-notify/issues/90#issuecomment-129333034)
> You can make it work by going to System > Notifications & Actions. The 'toast' app needs to have Banners enabled. (You can activate banners by clicking on the 'toast' app and setting the 'Show notification banners' to On)
[toaster](https://github.com/nels-o/toaster) is used to get native Windows Toasts!
```javascript
const WindowsToaster = require('node-notifier').WindowsToaster;
var notifier = new WindowsToaster({
withFallback: false, // Fallback to Growl or Balloons?
customPath: void 0 // Relative path if you want to use your fork of toast.exe
});
notifier.notify({
title: void 0,
message: void 0,
icon: void 0, // Absolute path to Icon
sound: false, // true | false.
wait: false, // Wait for User Action against Notification
}, function(error, response) {
console.log(response);
});
```
### Usage Growl
```javascript
const Growl = require('node-notifier').Growl;
var notifier = new Growl({
name: 'Growl Name Used', // Defaults as 'Node'
host: 'localhost',
port: 23053
});
notifier.notify({
title: 'Foo',
message: 'Hello World',
icon: fs.readFileSync(__dirname + "/coulson.jpg"),
wait: false, // Wait for User Action against Notification
// and other growl options like sticky etc.
sticky: false,
label: void 0,
priority: void 0
});
```
See more information about using
[growly](https://github.com/theabraham/growly/).
### Usage WindowsBalloon
For earlier Windows versions, the taskbar balloons are used (unless
fallback is activated and Growl is running). For balloons, a great
project called [notifu](http://www.paralint.com/projects/notifu/) is used.
```javascript
const WindowsBalloon = require('node-notifier').WindowsBalloon;
var notifier = new WindowsBalloon({
withFallback: false, // Try Windows Toast and Growl first?
customPath: void 0 // Relative path if you want to use your fork of notifu
});
notifier.notify({
title: void 0,
message: void 0,
sound: false, // true | false.
time: 5000, // How long to show balloon in ms
wait: false, // Wait for User Action against Notification
type: 'info' // The notification type : info | warn | error
}, function(error, response) {
console.log(response);
});
```
See full usage on the [project homepage:
notifu](http://www.paralint.com/projects/notifu/).
### Usage NotifySend
Note: notify-send doesn't support the wait flag.
```javascript
const NotifySend = require('node-notifier').NotifySend;
var notifier = new NotifySend();
notifier.notify({
title: 'Foo',
message: 'Hello World',
icon: __dirname + "/coulson.jpg",
// .. and other notify-send flags:
urgency: void 0,
time: void 0,
category: void 0,
hint: void 0,
});
```
See flags and options [on the man pages](http://manpages.ubuntu.com/manpages/gutsy/man1/notify-send.1.html)
## CLI
You can also use node-notifier as a CLI (as of `v4.2.0`).
```shell
$ notify -h
# notify
## Options
* --help (alias -h)
* --title (alias -t)
* --subtitle (alias -st)
* --message (alias -m)
* --icon (alias -i)
* --sound (alias -s)
* --open (alias -o)
## Example
$ notify -t "Hello" -m "My Message" -s --open http://github.com
$ notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg -m "Well, that's new. "
$ notify -m "My Message" -s Glass
$ echo "My Message" | notify -t "Hello"
```
You can also pass message in as `stdin`:
```js
echo "Message" | notify
# Works with existing arguments
echo "Message" | notify -t "My Title"
echo "Some message" | notify -t "My Title" -s
```
## Thanks to OSS
`node-notifier` is made possible through Open Source Software. A very special thanks to all the modules `node-notifier` uses.
* [terminal-notifier](https://github.com/alloy/terminal-notifier)
* [toaster](https://github.com/nels-o/toaster)
* [notifu](http://www.paralint.com/projects/notifu/)
* [growly](https://github.com/theabraham/growly/)
[![NPM downloads][npm-downloads]][npm-url]
## Common Issues
### Use inside tmux session
When using node-notifier within a tmux session, it can cause a hang in the system. This can be solved by following the steps described in this comment: https://github.com/julienXX/terminal-notifier/issues/115#issuecomment-104214742
See more info here: https://github.com/mikaelbr/node-notifier/issues/61#issuecomment-163560801
### Within Electron Packaging
If packaging your Electron app as an `asar`, you will find node-notifier will fail to load. Due to the way asar works, you cannot execute a binary from within an asar. As a simple solution, when packaging the app into an asar please make sure you `--unpack` the vendor folder of node-notifier, so the module still has access to the notification binaries. To do this, you can do so by using the following command:
```bash
asar pack . app.asar --unpack "./node_modules/node-notifier/vendor/**"
```
### Using Webpack
When using node-notifier inside of webpack, you must add the following snippet to your `webpack.config.js`. The reason this is required, is because node-notifier loads the notifiers from a binary, and so a relative file path is needed. When webpack compiles the modules, it supresses file directories, causing node-notifier to error on certain platforms. To fix/workaround this, you must tell webpack to keep the relative file directories, by doing so, append the following code to your `webpack.config.js`
```javascript
node: {
__filename: true,
__dirname: true
}
```
## License
[MIT License](http://en.wikipedia.org/wiki/MIT_License)
[npm-url]: https://npmjs.org/package/node-notifier
[npm-image]: http://img.shields.io/npm/v/node-notifier.svg?style=flat
[npm-downloads]: http://img.shields.io/npm/dm/node-notifier.svg?style=flat
[travis-url]: http://travis-ci.org/mikaelbr/node-notifier
[travis-image]: http://img.shields.io/travis/mikaelbr/node-notifier.svg?style=flat
[depstat-url]: https://gemnasium.com/mikaelbr/node-notifier
[depstat-image]: http://img.shields.io/gemnasium/mikaelbr/node-notifier.svg?style=flat
+99
View File
@@ -0,0 +1,99 @@
#!/usr/bin/env node
var Notification = require('./').Notification;
var minimist = require('minimist');
var usage = require('cli-usage');
var aliases = {
'help': 'h',
'title': 't',
'subtitle': 'st',
'message': 'm',
'icon': 'i',
'sound': 's',
'open': 'o',
'port': 'p',
};
var argv = minimist(process.argv.slice(2), {
alias: aliases,
string: ['icon', 'message', 'open', 'subtitle', 'title', 'host', 'port']
});
readme(aliases, ['host']);
var validOpts = Object.keys(aliases).concat('host');
var passedOptions = getOptionsIfExists(validOpts, argv);
var stdinMessage = '';
if (process.stdin.isTTY) {
doNotification(passedOptions);
} else {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(data) {
if (data) {
stdinMessage += data;
} else {
doNotification(passedOptions);
this.end();
return;
}
});
process.stdin.on('end', function(){
if (stdinMessage) {
passedOptions.message = stdinMessage;
}
doNotification(passedOptions);
});
}
function doNotification (options) {
var notifier = new Notification(options);
if (!options.message) {
// Do not show an empty message
process.exit(0);
}
notifier.notify(options, function (err, msg) {
if (err) {
console.error(err.message);
process.exit(1);
}
if (!msg) return;
console.log(msg);
process.exit(0);
});
}
function getOptionsIfExists(optionTypes, argv) {
var options = {};
optionTypes.forEach(function (key) {
if (key && argv[key]) {
options[key] = argv[key];
}
});
return options;
}
function readme(input, extra) {
var str = '# notify\n \n## Options\n' + params(input, extra) + '\n\n';
str += '## Example\n```shell\n';
str += '$ notify -t "Hello" -m "My Message" -s --open http://github.com\n';
str += '$ notify -t "Agent Coulson" --icon https://raw.githubusercontent.com/mikaelbr/node-notifier/master/example/coulson.jpg \n';
str += '$ notify -m "My Message" -s Glass\n';
str += '$ echo "My Message" | notify -t "Hello"```\n\n';
usage(str);
}
function params(input, extra) {
var withAlias = Object.keys(input).reduce(function (acc, key) {
return acc + ' * --' + key + ' (alias -' + input[key] + ')\n';
}, '');
if (!extra) return withAlias;
return withAlias + extra.reduce(function (acc, key) {
return acc + ' * --' + key + '\n';
}, '')
}
+41
View File
@@ -0,0 +1,41 @@
var os = require('os');
var utils = require('./lib/utils');
// All notifiers
var NotifySend = require('./notifiers/notifysend');
var NotificationCenter = require('./notifiers/notificationcenter');
var WindowsToaster = require('./notifiers/toaster');
var Growl = require('./notifiers/growl');
var WindowsBalloon = require('./notifiers/balloon');
var options = { withFallback: true };
switch(os.type()) {
case 'Linux':
module.exports = new NotifySend(options);
module.exports.Notification = NotifySend;
break;
case 'Darwin':
module.exports = new NotificationCenter(options);
module.exports.Notification = NotificationCenter;
break;
case 'Windows_NT':
if (utils.isLessThanWin8()) {
module.exports = new WindowsBalloon(options);
module.exports.Notification = WindowsBalloon;
} else {
module.exports = new WindowsToaster(options);
module.exports.Notification = WindowsToaster;
}
break;
default:
module.exports = new Growl(options);
module.exports.Notification = Growl;
}
// Expose notifiers to give full control.
module.exports.NotifySend = NotifySend;
module.exports.NotificationCenter = NotificationCenter;
module.exports.WindowsToaster = WindowsToaster;
module.exports.WindowsBalloon = WindowsBalloon;
module.exports.Growl = Growl;
+25
View File
@@ -0,0 +1,25 @@
var net = require('net');
var hasGrowl = false;
module.exports = function (growlConfig, cb) {
if (typeof cb == 'undefined') {
cb = growlConfig;
growlConfig = {};
}
if (hasGrowl) return cb(hasGrowl);
var port = growlConfig.port || 23053;
var host = growlConfig.host || 'localhost';
var socket = net.connect(port, host);
socket.setTimeout(100);
socket.on('connect', function() {
socket.end();
cb(true);
});
socket.on('error', function() {
socket.end();
cb(false);
});
};
+358
View File
@@ -0,0 +1,358 @@
var cp = require('child_process'),
os = require('os'),
fs = require('fs'),
url = require('url'),
path = require('path'),
shellwords = require('shellwords'),
semver = require('semver'),
clone = require('lodash.clonedeep');
var escapeQuotes = function (str) {
if (typeof str === 'string') {
return str.replace(/(["$`\\])/g, '\\$1');
} else {
return str;
}
};
var inArray = function (arr, val) {
for(var i = 0; i < arr.length; i++) {
if (arr[i] === val) {
return true;
}
}
return false;
};
var notifySendFlags = {
"u": "urgency",
"urgency": "urgency",
"t": "expire-time",
"e": "expire-time",
"expire": "expire-time",
"expire-time": "expire-time",
"i": "icon",
"icon": "icon",
"c": "category",
"category": "category",
"subtitle": "category",
"h": "hint",
"hint": "hint"
};
module.exports.command = function (notifier, options, cb) {
notifier = shellwords.escape(notifier);
return cp.exec(notifier + ' ' + options.join(' '), function (error, stdout, stderr) {
if (error) return cb(error);
cb(stderr, stdout);
});
};
module.exports.fileCommand = function (notifier, options, cb) {
return cp.execFile(notifier, options, function (error, stdout, stderr) {
if (error) return cb(error, stdout);
cb(stderr, stdout);
});
};
module.exports.immediateFileCommand = function (notifier, options, cb) {
notifierExists(notifier, function (exists) {
if (!exists) return cb(new Error('Notifier (' + notifier + ') not found on system.'));
cp.execFile(notifier, options);
cb();
});
};
function notifierExists (notifier, cb) {
return fs.stat(notifier, function (err, stat) {
if (!err) return cb(stat.isFile());
// Check if Windows alias
if (!!path.extname(notifier)) {
// Has extentioon, no need to check more
return cb(false);
}
// Check if there is an exe file in the directory
return fs.stat(notifier + '.exe', function (err, stat) {
cb(stat.isFile());
});
});
}
var mapAppIcon = function (options) {
if (options.appIcon) {
options.icon = options.appIcon;
delete options.appIcon;
}
return options;
};
var mapText = function (options) {
if (options.text) {
options.message = options.text;
delete options.text;
}
return options;
};
var mapIconShorthand = function (options) {
if (options.i) {
options.icon = options.i;
delete options.i;
}
return options;
};
module.exports.mapToNotifySend = function (options) {
options = mapAppIcon(options);
options = mapText(options);
for (var key in options) {
if (key === "message" || key === "title") continue;
if (options.hasOwnProperty(key) && (notifySendFlags[key] != key)) {
options[notifySendFlags[key]] = options[key];
delete options[key];
}
}
return options;
};
module.exports.mapToGrowl = function (options) {
options = mapAppIcon(options);
options = mapIconShorthand(options);
options = mapText(options);
if (options.icon && !Buffer.isBuffer(options.icon)) {
try {
options.icon = fs.readFileSync(options.icon);
}catch(ex){
}
}
return options;
};
module.exports.mapToMac = function (options) {
options = mapIconShorthand(options);
options = mapText(options);
if (options.icon) {
options.appIcon = options.icon;
delete options.icon;
}
if (options.sound === true) {
options.sound = 'Bottle';
}
if (options.sound === false) {
delete options.sound;
}
return options;
};
module.exports.actionJackerDecorator = function (emitter, options, fn, mapper) {
options = clone(options);
fn = fn || function (err, data) {};
return function (err, data) {
var resultantData = data;
// Sanitize the data
if(resultantData) {
resultantData = resultantData.toLowerCase().trim();
if(resultantData.match(/^activate/)) {
resultantData = 'activate';
}
}
fn.apply(emitter, [err, resultantData]);
if (err || !mapper || !resultantData) return;
var key = mapper(resultantData);
if (!key) return;
emitter.emit(key, emitter, options);
};
};
module.exports.constructArgumentList = function (options, extra) {
var args = [];
extra = extra || {};
// Massive ugly setup. Default args
var initial = extra.initial || [];
var keyExtra = extra.keyExtra || "";
var allowedArguments = extra.allowedArguments || [];
var noEscape = extra.noEscape !== void 0;
var checkForAllowed = extra.allowedArguments !== void 0;
var explicitTrue = !!extra.explicitTrue;
var wrapper = extra.wrapper === void 0 ? '"' : extra.wrapper;
var escapeFn = function(arg) {
if (!noEscape) {
arg = escapeQuotes(arg);
}
if(typeof arg === 'string'){
arg = arg.replace(/\r?\n/g, '\\n');
}
return arg;
}
initial.forEach(function (val) {
args.push(wrapper + escapeFn(val) + wrapper);
});
for(var key in options) {
if (options.hasOwnProperty(key) && (!checkForAllowed || inArray(allowedArguments, key))) {
if (explicitTrue && options[key] === true) args.push('-' + keyExtra + key);
else if (explicitTrue && options[key] === false) continue;
else args.push('-' + keyExtra + key, wrapper + escapeFn(options[key]) + wrapper);
}
}
return args;
};
module.exports.mapToWin8 = function (options){
options = mapAppIcon(options);
options = mapText(options);
if(options.icon){
if (/^file:\/+/.test(options.icon)) {
// should parse file protocol URL to path
options.p = url.parse(options.icon).pathname.replace(/^\/(\w\:\/)/, "$1").replace(/\//g, "\\");
} else {
options.p = options.icon;
}
delete options.icon;
}
if(options.message){
// Remove escape char to debug "HRESULT : 0xC00CE508" exception
options.m = options.message.replace(/\x1b/g, '');
delete options.message;
}
if (options.title) {
options.t = options.title;
delete options.title;
}
if (options.quiet || options.silent) {
options.q = options.quiet || options.silent;
delete options.quiet;
delete options.silent;
}
if (options.q !== false) {
options.q = true;
} else {
delete options.q;
}
if (options.sound) {
delete options.q;
delete options.sound;
}
if (options.wait) {
options.w = options.wait;
delete options.wait;
}
return options;
};
module.exports.mapToNotifu = function (options) {
options = mapAppIcon(options);
options = mapText(options);
if(options.icon){
options.i = options.icon;
delete options.icon;
}
if(options.message){
options.m = options.message;
delete options.message;
}
if (options.title) {
options.p = options.title;
delete options.title;
}
if (options.time) {
options.d = options.time;
delete options.time;
}
if (options.q !== false) {
options.q = true;
} else {
delete options.q;
}
if (options.quiet === false) {
delete options.q;
delete options.quiet;
}
if (options.sound) {
delete options.q;
delete options.sound;
}
if (options.t) {
options.d = options.t;
delete options.t;
}
if (options.type) {
options.t = sanitizeNotifuTypeArgument(options.type);
delete options.type;
}
return options;
};
module.exports.isMac = function() {
return os.type() === 'Darwin';
};
module.exports.isMountainLion = function() {
return os.type() === 'Darwin' && semver.satisfies(garanteeSemverFormat(os.release()), '>=12.0.0');
};
module.exports.isWin8 = function() {
return os.type() === 'Windows_NT' && semver.satisfies(garanteeSemverFormat(os.release()), '>=6.2.9200');
};
module.exports.isLessThanWin8 = function() {
return os.type() === 'Windows_NT' && semver.satisfies(garanteeSemverFormat(os.release()), '<6.2.9200');
};
function garanteeSemverFormat (version) {
if (version.split('.').length === 2) {
version += '.0';
}
return version;
}
function sanitizeNotifuTypeArgument(type) {
if (typeof type === 'string' || type instanceof String) {
if (type.toLowerCase() == 'info')
return 'info';
if (type.toLowerCase() == 'warn')
return 'warn';
if (type.toLowerCase() == 'error')
return 'error';
}
return 'info';
}
+22
View File
@@ -0,0 +1,22 @@
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
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.
+20
View File
@@ -0,0 +1,20 @@
# lodash.clonedeep v3.0.2
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodashs](https://lodash.com/) `_.cloneDeep` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module.
## Installation
Using npm:
```bash
$ {sudo -H} npm i -g npm
$ npm i --save lodash.clonedeep
```
In Node.js/io.js:
```js
var cloneDeep = require('lodash.clonedeep');
```
See the [documentation](https://lodash.com/docs#cloneDeep) or [package source](https://github.com/lodash/lodash/blob/3.0.2-npm-packages/lodash.clonedeep) for more details.
+63
View File
@@ -0,0 +1,63 @@
/**
* lodash 3.0.2 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var baseClone = require('lodash._baseclone'),
bindCallback = require('lodash._bindcallback');
/**
* Creates a deep clone of `value`. If `customizer` is provided it's invoked
* to produce the cloned values. If `customizer` returns `undefined` cloning
* is handled by the method instead. The `customizer` is bound to `thisArg`
* and invoked with up to three argument; (value [, index|key, object]).
*
* **Note:** This method is loosely based on the
* [structured clone algorithm](http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm).
* The enumerable properties of `arguments` objects and objects created by
* constructors other than `Object` are cloned to plain `Object` objects. An
* empty object is returned for uncloneable values such as functions, DOM nodes,
* Maps, Sets, and WeakMaps.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to deep clone.
* @param {Function} [customizer] The function to customize cloning values.
* @param {*} [thisArg] The `this` binding of `customizer`.
* @returns {*} Returns the deep cloned value.
* @example
*
* var users = [
* { 'user': 'barney' },
* { 'user': 'fred' }
* ];
*
* var deep = _.cloneDeep(users);
* deep[0] === users[0];
* // => false
*
* // using a customizer callback
* var el = _.cloneDeep(document.body, function(value) {
* if (_.isElement(value)) {
* return value.cloneNode(true);
* }
* });
*
* el === document.body
* // => false
* el.nodeName
* // => BODY
* el.childNodes.length;
* // => 20
*/
function cloneDeep(value, customizer, thisArg) {
return typeof customizer == 'function'
? baseClone(value, true, bindCallback(customizer, thisArg, 3))
: baseClone(value, true);
}
module.exports = cloneDeep;
+132
View File
@@ -0,0 +1,132 @@
{
"_args": [
[
{
"raw": "lodash.clonedeep@^3.0.0",
"scope": null,
"escapedName": "lodash.clonedeep",
"name": "lodash.clonedeep",
"rawSpec": "^3.0.0",
"spec": ">=3.0.0 <4.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier"
]
],
"_from": "lodash.clonedeep@>=3.0.0 <4.0.0",
"_id": "lodash.clonedeep@3.0.2",
"_inCache": true,
"_location": "/node-notifier/lodash.clonedeep",
"_nodeVersion": "0.12.5",
"_npmUser": {
"name": "jdalton",
"email": "john.david.dalton@gmail.com"
},
"_npmVersion": "2.13.1",
"_phantomChildren": {},
"_requested": {
"raw": "lodash.clonedeep@^3.0.0",
"scope": null,
"escapedName": "lodash.clonedeep",
"name": "lodash.clonedeep",
"rawSpec": "^3.0.0",
"spec": ">=3.0.0 <4.0.0",
"type": "range"
},
"_requiredBy": [
"/node-notifier"
],
"_resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-3.0.2.tgz",
"_shasum": "a0a1e40d82a5ea89ff5b147b8444ed63d92827db",
"_shrinkwrap": null,
"_spec": "lodash.clonedeep@^3.0.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier",
"author": {
"name": "John-David Dalton",
"email": "john.david.dalton@gmail.com",
"url": "http://allyoucanleet.com/"
},
"bugs": {
"url": "https://github.com/lodash/lodash/issues"
},
"contributors": [
{
"name": "John-David Dalton",
"email": "john.david.dalton@gmail.com",
"url": "http://allyoucanleet.com/"
},
{
"name": "Benjamin Tan",
"email": "demoneaux@gmail.com",
"url": "https://d10.github.io/"
},
{
"name": "Blaine Bublitz",
"email": "blaine@iceddev.com",
"url": "http://www.iceddev.com/"
},
{
"name": "Kit Cambridge",
"email": "github@kitcambridge.be",
"url": "http://kitcambridge.be/"
},
{
"name": "Mathias Bynens",
"email": "mathias@qiwi.be",
"url": "https://mathiasbynens.be/"
}
],
"dependencies": {
"lodash._baseclone": "^3.0.0",
"lodash._bindcallback": "^3.0.0"
},
"description": "The modern build of lodashs `_.cloneDeep` as a module.",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "a0a1e40d82a5ea89ff5b147b8444ed63d92827db",
"tarball": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-3.0.2.tgz"
},
"homepage": "https://lodash.com/",
"icon": "https://lodash.com/icon.svg",
"keywords": [
"lodash",
"lodash-modularized",
"stdlib",
"util"
],
"license": "MIT",
"maintainers": [
{
"name": "jdalton",
"email": "john.david.dalton@gmail.com"
},
{
"name": "kitcambridge",
"email": "github@kitcambridge.be"
},
{
"name": "mathias",
"email": "mathias@qiwi.be"
},
{
"name": "phated",
"email": "blaine@iceddev.com"
},
{
"name": "d10",
"email": "demoneaux@gmail.com"
}
],
"name": "lodash.clonedeep",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/lodash/lodash.git"
},
"scripts": {
"test": "echo \"See https://travis-ci.org/lodash/lodash-cli for testing details.\""
},
"version": "3.0.2"
}
+8
View File
@@ -0,0 +1,8 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.12"
- "iojs"
before_install:
- npm install -g npm@~1.4.6
+18
View File
@@ -0,0 +1,18 @@
This software is released under the MIT license:
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.
+2
View File
@@ -0,0 +1,2 @@
var argv = require('../')(process.argv.slice(2));
console.dir(argv);
+236
View File
@@ -0,0 +1,236 @@
module.exports = function (args, opts) {
if (!opts) opts = {};
var flags = { bools : {}, strings : {}, unknownFn: null };
if (typeof opts['unknown'] === 'function') {
flags.unknownFn = opts['unknown'];
}
if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
flags.allBools = true;
} else {
[].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
flags.bools[key] = true;
});
}
var aliases = {};
Object.keys(opts.alias || {}).forEach(function (key) {
aliases[key] = [].concat(opts.alias[key]);
aliases[key].forEach(function (x) {
aliases[x] = [key].concat(aliases[key].filter(function (y) {
return x !== y;
}));
});
});
[].concat(opts.string).filter(Boolean).forEach(function (key) {
flags.strings[key] = true;
if (aliases[key]) {
flags.strings[aliases[key]] = true;
}
});
var defaults = opts['default'] || {};
var argv = { _ : [] };
Object.keys(flags.bools).forEach(function (key) {
setArg(key, defaults[key] === undefined ? false : defaults[key]);
});
var notFlags = [];
if (args.indexOf('--') !== -1) {
notFlags = args.slice(args.indexOf('--')+1);
args = args.slice(0, args.indexOf('--'));
}
function argDefined(key, arg) {
return (flags.allBools && /^--[^=]+$/.test(arg)) ||
flags.strings[key] || flags.bools[key] || aliases[key];
}
function setArg (key, val, arg) {
if (arg && flags.unknownFn && !argDefined(key, arg)) {
if (flags.unknownFn(arg) === false) return;
}
var value = !flags.strings[key] && isNumber(val)
? Number(val) : val
;
setKey(argv, key.split('.'), value);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), value);
});
}
function setKey (obj, keys, value) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
if (o[key] === undefined) o[key] = {};
o = o[key];
});
var key = keys[keys.length - 1];
if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
o[key] = value;
}
else if (Array.isArray(o[key])) {
o[key].push(value);
}
else {
o[key] = [ o[key], value ];
}
}
function aliasIsBoolean(key) {
return aliases[key].some(function (x) {
return flags.bools[x];
});
}
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (/^--.+=/.test(arg)) {
// Using [\s\S] instead of . because js doesn't support the
// 'dotall' regex modifier. See:
// http://stackoverflow.com/a/1068308/13216
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
var key = m[1];
var value = m[2];
if (flags.bools[key]) {
value = value !== 'false';
}
setArg(key, value, arg);
}
else if (/^--no-.+/.test(arg)) {
var key = arg.match(/^--no-(.+)/)[1];
setArg(key, false, arg);
}
else if (/^--.+/.test(arg)) {
var key = arg.match(/^--(.+)/)[1];
var next = args[i + 1];
if (next !== undefined && !/^-/.test(next)
&& !flags.bools[key]
&& !flags.allBools
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, next, arg);
i++;
}
else if (/^(true|false)$/.test(next)) {
setArg(key, next === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
else if (/^-[^-]+/.test(arg)) {
var letters = arg.slice(1,-1).split('');
var broken = false;
for (var j = 0; j < letters.length; j++) {
var next = arg.slice(j+2);
if (next === '-') {
setArg(letters[j], next, arg)
continue;
}
if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
setArg(letters[j], next.split('=')[1], arg);
broken = true;
break;
}
if (/[A-Za-z]/.test(letters[j])
&& /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
setArg(letters[j], next, arg);
broken = true;
break;
}
if (letters[j+1] && letters[j+1].match(/\W/)) {
setArg(letters[j], arg.slice(j+2), arg);
broken = true;
break;
}
else {
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
}
}
var key = arg.slice(-1)[0];
if (!broken && key !== '-') {
if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
&& !flags.bools[key]
&& (aliases[key] ? !aliasIsBoolean(key) : true)) {
setArg(key, args[i+1], arg);
i++;
}
else if (args[i+1] && /true|false/.test(args[i+1])) {
setArg(key, args[i+1] === 'true', arg);
i++;
}
else {
setArg(key, flags.strings[key] ? '' : true, arg);
}
}
}
else {
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
argv._.push(
flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
);
}
if (opts.stopEarly) {
argv._.push.apply(argv._, args.slice(i + 1));
break;
}
}
}
Object.keys(defaults).forEach(function (key) {
if (!hasKey(argv, key.split('.'))) {
setKey(argv, key.split('.'), defaults[key]);
(aliases[key] || []).forEach(function (x) {
setKey(argv, x.split('.'), defaults[key]);
});
}
});
if (opts['--']) {
argv['--'] = new Array();
notFlags.forEach(function(key) {
argv['--'].push(key);
});
}
else {
notFlags.forEach(function(key) {
argv._.push(key);
});
}
return argv;
};
function hasKey (obj, keys) {
var o = obj;
keys.slice(0,-1).forEach(function (key) {
o = (o[key] || {});
});
var key = keys[keys.length - 1];
return key in o;
}
function isNumber (x) {
if (typeof x === 'number') return true;
if (/^0x[0-9a-f]+$/i.test(x)) return true;
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
}
+105
View File
@@ -0,0 +1,105 @@
{
"_args": [
[
{
"raw": "minimist@^1.1.1",
"scope": null,
"escapedName": "minimist",
"name": "minimist",
"rawSpec": "^1.1.1",
"spec": ">=1.1.1 <2.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier"
]
],
"_from": "minimist@>=1.1.1 <2.0.0",
"_id": "minimist@1.2.0",
"_inCache": true,
"_location": "/node-notifier/minimist",
"_nodeVersion": "2.4.0",
"_npmUser": {
"name": "substack",
"email": "substack@gmail.com"
},
"_npmVersion": "3.2.2",
"_phantomChildren": {},
"_requested": {
"raw": "minimist@^1.1.1",
"scope": null,
"escapedName": "minimist",
"name": "minimist",
"rawSpec": "^1.1.1",
"spec": ">=1.1.1 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/node-notifier"
],
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"_shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
"_shrinkwrap": null,
"_spec": "minimist@^1.1.1",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\node-notifier",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/minimist/issues"
},
"dependencies": {},
"description": "parse argument options",
"devDependencies": {
"covert": "^1.0.0",
"tap": "~0.4.0",
"tape": "^3.5.0"
},
"directories": {},
"dist": {
"shasum": "a35008b20f41383eec1fb914f4cd5df79a264284",
"tarball": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz"
},
"gitHead": "dc624482fcfec5bc669c68cdb861f00573ed4e64",
"homepage": "https://github.com/substack/minimist",
"keywords": [
"argv",
"getopt",
"parser",
"optimist"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "substack",
"email": "mail@substack.net"
}
],
"name": "minimist",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/substack/minimist.git"
},
"scripts": {
"coverage": "covert test/*.js",
"test": "tap test/*.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/6..latest",
"ff/5",
"firefox/latest",
"chrome/10",
"chrome/latest",
"safari/5.1",
"safari/latest",
"opera/12"
]
},
"version": "1.2.0"
}
+91
View File
@@ -0,0 +1,91 @@
# minimist
parse argument options
This module is the guts of optimist's argument parser without all the
fanciful decoration.
[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
# example
``` js
var argv = require('minimist')(process.argv.slice(2));
console.dir(argv);
```
```
$ node example/parse.js -a beep -b boop
{ _: [], a: 'beep', b: 'boop' }
```
```
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
{ _: [ 'foo', 'bar', 'baz' ],
x: 3,
y: 4,
n: 5,
a: true,
b: true,
c: true,
beep: 'boop' }
```
# methods
``` js
var parseArgs = require('minimist')
```
## var argv = parseArgs(args, opts={})
Return an argument object `argv` populated with the array arguments from `args`.
`argv._` contains all the arguments that didn't have an option associated with
them.
Numeric-looking arguments will be returned as numbers unless `opts.string` or
`opts.boolean` is set for that argument name.
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
options can be:
* `opts.string` - a string or array of strings argument names to always treat as
strings
* `opts.boolean` - a boolean, string or array of strings to always treat as
booleans. if `true` will treat all double hyphenated arguments without equal signs
as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
* `opts.alias` - an object mapping string names to strings or arrays of string
argument names to use as aliases
* `opts.default` - an object mapping string argument names to default values
* `opts.stopEarly` - when true, populate `argv._` with everything after the
first non-option
* `opts['--']` - when true, populate `argv._` with everything before the `--`
and `argv['--']` with everything after the `--`. Here's an example:
* `opts.unknown` - a function which is invoked with a command line parameter not
defined in the `opts` configuration object. If the function returns `false`, the
unknown option is not added to `argv`.
```
> require('./')('one two three -- four five --six'.split(' '), { '--': true })
{ _: [ 'one', 'two', 'three' ],
'--': [ 'four', 'five', '--six' ] }
```
Note that with `opts['--']` set, parsing for arguments still stops after the
`--`.
# install
With [npm](https://npmjs.org) do:
```
npm install minimist
```
# license
MIT
+32
View File
@@ -0,0 +1,32 @@
var parse = require('../');
var test = require('tape');
test('flag boolean true (default all --args to boolean)', function (t) {
var argv = parse(['moo', '--honk', 'cow'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
test('flag boolean true only affects double hyphen arguments without equals signs', function (t) {
var argv = parse(['moo', '--honk', 'cow', '-p', '55', '--tacos=good'], {
boolean: true
});
t.deepEqual(argv, {
honk: true,
tacos: 'good',
p: 55,
_: ['moo', 'cow']
});
t.deepEqual(typeof argv.honk, 'boolean');
t.end();
});
+166
View File
@@ -0,0 +1,166 @@
var parse = require('../');
var test = require('tape');
test('flag boolean default false', function (t) {
var argv = parse(['moo'], {
boolean: ['t', 'verbose'],
default: { verbose: false, t: false }
});
t.deepEqual(argv, {
verbose: false,
t: false,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('boolean groups', function (t) {
var argv = parse([ '-x', '-z', 'one', 'two', 'three' ], {
boolean: ['x','y','z']
});
t.deepEqual(argv, {
x : true,
y : false,
z : true,
_ : [ 'one', 'two', 'three' ]
});
t.deepEqual(typeof argv.x, 'boolean');
t.deepEqual(typeof argv.y, 'boolean');
t.deepEqual(typeof argv.z, 'boolean');
t.end();
});
test('boolean and alias with chainable api', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
herp: { alias: 'h', boolean: true }
};
var aliasedArgv = parse(aliased, {
boolean: 'herp',
alias: { h: 'herp' }
});
var propertyArgv = parse(regular, {
boolean: 'herp',
alias: { h: 'herp' }
});
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var opts = {
alias: { 'h': 'herp' },
boolean: 'herp'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
test('boolean and alias array with options hash', function (t) {
var aliased = [ '-h', 'derp' ];
var regular = [ '--herp', 'derp' ];
var alt = [ '--harp', 'derp' ];
var opts = {
alias: { 'h': ['herp', 'harp'] },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var altPropertyArgv = parse(alt, opts);
var expected = {
harp: true,
herp: true,
h: true,
'_': [ 'derp' ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.same(altPropertyArgv, expected);
t.end();
});
test('boolean and alias using explicit true', function (t) {
var aliased = [ '-h', 'true' ];
var regular = [ '--herp', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h'
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
var expected = {
herp: true,
h: true,
'_': [ ]
};
t.same(aliasedArgv, expected);
t.same(propertyArgv, expected);
t.end();
});
// regression, see https://github.com/substack/node-optimist/issues/71
test('boolean and --x=true', function(t) {
var parsed = parse(['--boool', '--other=true'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'true');
parsed = parse(['--boool', '--other=false'], {
boolean: 'boool'
});
t.same(parsed.boool, true);
t.same(parsed.other, 'false');
t.end();
});
test('boolean --boool=true', function (t) {
var parsed = parse(['--boool=true'], {
default: {
boool: false
},
boolean: ['boool']
});
t.same(parsed.boool, true);
t.end();
});
test('boolean --boool=false', function (t) {
var parsed = parse(['--boool=false'], {
default: {
boool: true
},
boolean: ['boool']
});
t.same(parsed.boool, false);
t.end();
});
+31
View File
@@ -0,0 +1,31 @@
var parse = require('../');
var test = require('tape');
test('-', function (t) {
t.plan(5);
t.deepEqual(parse([ '-n', '-' ]), { n: '-', _: [] });
t.deepEqual(parse([ '-' ]), { _: [ '-' ] });
t.deepEqual(parse([ '-f-' ]), { f: '-', _: [] });
t.deepEqual(
parse([ '-b', '-' ], { boolean: 'b' }),
{ b: true, _: [ '-' ] }
);
t.deepEqual(
parse([ '-s', '-' ], { string: 's' }),
{ s: '-', _: [] }
);
});
test('-a -- b', function (t) {
t.plan(3);
t.deepEqual(parse([ '-a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
t.deepEqual(parse([ '--a', '--', 'b' ]), { a: true, _: [ 'b' ] });
});
test('move arguments after the -- into their own `--` array', function(t) {
t.plan(1);
t.deepEqual(
parse([ '--name', 'John', 'before', '--', 'after' ], { '--': true }),
{ name: 'John', _: [ 'before' ], '--': [ 'after' ] });
});
+35
View File
@@ -0,0 +1,35 @@
var test = require('tape');
var parse = require('../');
test('boolean default true', function (t) {
var argv = parse([], {
boolean: 'sometrue',
default: { sometrue: true }
});
t.equal(argv.sometrue, true);
t.end();
});
test('boolean default false', function (t) {
var argv = parse([], {
boolean: 'somefalse',
default: { somefalse: false }
});
t.equal(argv.somefalse, false);
t.end();
});
test('boolean default to null', function (t) {
var argv = parse([], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, null);
var argv = parse(['--maybe'], {
boolean: 'maybe',
default: { maybe: null }
});
t.equal(argv.maybe, true);
t.end();
})
+22
View File
@@ -0,0 +1,22 @@
var parse = require('../');
var test = require('tape');
test('dotted alias', function (t) {
var argv = parse(['--a.b', '22'], {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 22);
t.equal(argv.aa.bb, 22);
t.end();
});
test('dotted default', function (t) {
var argv = parse('', {default: {'a.b': 11}, alias: {'a.b': 'aa.bb'}});
t.equal(argv.a.b, 11);
t.equal(argv.aa.bb, 11);
t.end();
});
test('dotted default with no alias', function (t) {
var argv = parse('', {default: {'a.b': 11}});
t.equal(argv.a.b, 11);
t.end();
});
+16
View File
@@ -0,0 +1,16 @@
var parse = require('../');
var test = require('tape');
test('short -k=v' , function (t) {
t.plan(1);
var argv = parse([ '-b=123' ]);
t.deepEqual(argv, { b: 123, _: [] });
});
test('multi short -k=v' , function (t) {
t.plan(1);
var argv = parse([ '-a=whatever', '-b=robots' ]);
t.deepEqual(argv, { a: 'whatever', b: 'robots', _: [] });
});
+31
View File
@@ -0,0 +1,31 @@
var test = require('tape');
var parse = require('../');
test('long opts', function (t) {
t.deepEqual(
parse([ '--bool' ]),
{ bool : true, _ : [] },
'long boolean'
);
t.deepEqual(
parse([ '--pow', 'xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture sp'
);
t.deepEqual(
parse([ '--pow=xixxle' ]),
{ pow : 'xixxle', _ : [] },
'long capture eq'
);
t.deepEqual(
parse([ '--host', 'localhost', '--port', '555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures sp'
);
t.deepEqual(
parse([ '--host=localhost', '--port=555' ]),
{ host : 'localhost', port : 555, _ : [] },
'long captures eq'
);
t.end();
});
+36
View File
@@ -0,0 +1,36 @@
var parse = require('../');
var test = require('tape');
test('nums', function (t) {
var argv = parse([
'-x', '1234',
'-y', '5.67',
'-z', '1e7',
'-w', '10f',
'--hex', '0xdeadbeef',
'789'
]);
t.deepEqual(argv, {
x : 1234,
y : 5.67,
z : 1e7,
w : '10f',
hex : 0xdeadbeef,
_ : [ 789 ]
});
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv.y, 'number');
t.deepEqual(typeof argv.z, 'number');
t.deepEqual(typeof argv.w, 'string');
t.deepEqual(typeof argv.hex, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});
test('already a number', function (t) {
var argv = parse([ '-x', 1234, 789 ]);
t.deepEqual(argv, { x : 1234, _ : [ 789 ] });
t.deepEqual(typeof argv.x, 'number');
t.deepEqual(typeof argv._[0], 'number');
t.end();
});
+197
View File
@@ -0,0 +1,197 @@
var parse = require('../');
var test = require('tape');
test('parse args', function (t) {
t.deepEqual(
parse([ '--no-moo' ]),
{ moo : false, _ : [] },
'no'
);
t.deepEqual(
parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
{ v : ['a','b','c'], _ : [] },
'multi'
);
t.end();
});
test('comprehensive', function (t) {
t.deepEqual(
parse([
'--name=meowmers', 'bare', '-cats', 'woo',
'-h', 'awesome', '--multi=quux',
'--key', 'value',
'-b', '--bool', '--no-meep', '--multi=baz',
'--', '--not-a-flag', 'eek'
]),
{
c : true,
a : true,
t : true,
s : 'woo',
h : 'awesome',
b : true,
bool : true,
key : 'value',
multi : [ 'quux', 'baz' ],
meep : false,
name : 'meowmers',
_ : [ 'bare', '--not-a-flag', 'eek' ]
}
);
t.end();
});
test('flag boolean', function (t) {
var argv = parse([ '-t', 'moo' ], { boolean: 't' });
t.deepEqual(argv, { t : true, _ : [ 'moo' ] });
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('flag boolean value', function (t) {
var argv = parse(['--verbose', 'false', 'moo', '-t', 'true'], {
boolean: [ 't', 'verbose' ],
default: { verbose: true }
});
t.deepEqual(argv, {
verbose: false,
t: true,
_: ['moo']
});
t.deepEqual(typeof argv.verbose, 'boolean');
t.deepEqual(typeof argv.t, 'boolean');
t.end();
});
test('newlines in params' , function (t) {
var args = parse([ '-s', "X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
// reproduce in bash:
// VALUE="new
// line"
// node program.js --s="$VALUE"
args = parse([ "--s=X\nX" ])
t.deepEqual(args, { _ : [], s : "X\nX" });
t.end();
});
test('strings' , function (t) {
var s = parse([ '-s', '0001234' ], { string: 's' }).s;
t.equal(s, '0001234');
t.equal(typeof s, 'string');
var x = parse([ '-x', '56' ], { string: 'x' }).x;
t.equal(x, '56');
t.equal(typeof x, 'string');
t.end();
});
test('stringArgs', function (t) {
var s = parse([ ' ', ' ' ], { string: '_' })._;
t.same(s.length, 2);
t.same(typeof s[0], 'string');
t.same(s[0], ' ');
t.same(typeof s[1], 'string');
t.same(s[1], ' ');
t.end();
});
test('empty strings', function(t) {
var s = parse([ '-s' ], { string: 's' }).s;
t.equal(s, '');
t.equal(typeof s, 'string');
var str = parse([ '--str' ], { string: 'str' }).str;
t.equal(str, '');
t.equal(typeof str, 'string');
var letters = parse([ '-art' ], {
string: [ 'a', 't' ]
});
t.equal(letters.a, '');
t.equal(letters.r, true);
t.equal(letters.t, '');
t.end();
});
test('string and alias', function(t) {
var x = parse([ '--str', '000123' ], {
string: 's',
alias: { s: 'str' }
});
t.equal(x.str, '000123');
t.equal(typeof x.str, 'string');
t.equal(x.s, '000123');
t.equal(typeof x.s, 'string');
var y = parse([ '-s', '000123' ], {
string: 'str',
alias: { str: 's' }
});
t.equal(y.str, '000123');
t.equal(typeof y.str, 'string');
t.equal(y.s, '000123');
t.equal(typeof y.s, 'string');
t.end();
});
test('slashBreak', function (t) {
t.same(
parse([ '-I/foo/bar/baz' ]),
{ I : '/foo/bar/baz', _ : [] }
);
t.same(
parse([ '-xyz/foo/bar/baz' ]),
{ x : true, y : true, z : '/foo/bar/baz', _ : [] }
);
t.end();
});
test('alias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: 'zoom' }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.f, 11);
t.end();
});
test('multiAlias', function (t) {
var argv = parse([ '-f', '11', '--zoom', '55' ], {
alias: { z: [ 'zm', 'zoom' ] }
});
t.equal(argv.zoom, 55);
t.equal(argv.z, argv.zoom);
t.equal(argv.z, argv.zm);
t.equal(argv.f, 11);
t.end();
});
test('nested dotted objects', function (t) {
var argv = parse([
'--foo.bar', '3', '--foo.baz', '4',
'--foo.quux.quibble', '5', '--foo.quux.o_O',
'--beep.boop'
]);
t.same(argv.foo, {
bar : 3,
baz : 4,
quux : {
quibble : 5,
o_O : true
}
});
t.same(argv.beep, { boop : true });
t.end();
});
@@ -0,0 +1,9 @@
var parse = require('../');
var test = require('tape');
test('parse with modifier functions' , function (t) {
t.plan(1);
var argv = parse([ '-b', '123' ], { boolean: 'b' });
t.deepEqual(argv, { b: true, _: [123] });
});
+67
View File
@@ -0,0 +1,67 @@
var parse = require('../');
var test = require('tape');
test('numeric short args', function (t) {
t.plan(2);
t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
t.deepEqual(
parse([ '-123', '456' ]),
{ 1: true, 2: true, 3: 456, _: [] }
);
});
test('short', function (t) {
t.deepEqual(
parse([ '-b' ]),
{ b : true, _ : [] },
'short boolean'
);
t.deepEqual(
parse([ 'foo', 'bar', 'baz' ]),
{ _ : [ 'foo', 'bar', 'baz' ] },
'bare'
);
t.deepEqual(
parse([ '-cats' ]),
{ c : true, a : true, t : true, s : true, _ : [] },
'group'
);
t.deepEqual(
parse([ '-cats', 'meow' ]),
{ c : true, a : true, t : true, s : 'meow', _ : [] },
'short group next'
);
t.deepEqual(
parse([ '-h', 'localhost' ]),
{ h : 'localhost', _ : [] },
'short capture'
);
t.deepEqual(
parse([ '-h', 'localhost', '-p', '555' ]),
{ h : 'localhost', p : 555, _ : [] },
'short captures'
);
t.end();
});
test('mixed short bool and capture', function (t) {
t.same(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});
test('short and long', function (t) {
t.deepEqual(
parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
{
f : true, p : 555, h : 'localhost',
_ : [ 'script.js' ]
}
);
t.end();
});
+15
View File
@@ -0,0 +1,15 @@
var parse = require('../');
var test = require('tape');
test('stops parsing on the first non-option when stopEarly is set', function (t) {
var argv = parse(['--aaa', 'bbb', 'ccc', '--ddd'], {
stopEarly: true
});
t.deepEqual(argv, {
aaa: 'bbb',
_: ['ccc', '--ddd']
});
t.end();
});
+102
View File
@@ -0,0 +1,102 @@
var parse = require('../');
var test = require('tape');
test('boolean and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'true', '--derp', 'true' ];
var regular = [ '--herp', 'true', '-d', 'true' ];
var opts = {
alias: { h: 'herp' },
boolean: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('flag boolean true any double hyphen argument is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var argv = parse(['--honk', '--tacos=good', 'cow', '-p', '55'], {
boolean: true,
unknown: unknownFn
});
t.same(unknown, ['--tacos=good', 'cow', '-p']);
t.same(argv, {
honk: true,
_: []
});
t.end();
});
test('string and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello', '--derp', 'goodbye' ];
var regular = [ '--herp', 'hello', '-d', 'moon' ];
var opts = {
alias: { h: 'herp' },
string: 'h',
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, ['--derp', '-d']);
t.end();
});
test('default and alias is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '-h', 'hello' ];
var regular = [ '--herp', 'hello' ];
var opts = {
default: { 'h': 'bar' },
alias: { 'h': 'herp' },
unknown: unknownFn
};
var aliasedArgv = parse(aliased, opts);
var propertyArgv = parse(regular, opts);
t.same(unknown, []);
t.end();
unknownFn(); // exercise fn for 100% coverage
});
test('value following -- is not unknown', function (t) {
var unknown = [];
function unknownFn(arg) {
unknown.push(arg);
return false;
}
var aliased = [ '--bad', '--', 'good', 'arg' ];
var opts = {
'--': true,
unknown: unknownFn
};
var argv = parse(aliased, opts);
t.same(unknown, ['--bad']);
t.same(argv, {
'--': ['good', 'arg'],
'_': []
})
t.end();
});
+8
View File
@@ -0,0 +1,8 @@
var parse = require('../');
var test = require('tape');
test('whitespace should be whitespace' , function (t) {
t.plan(1);
var x = parse([ '-x', '\t' ]).x;
t.equal(x, '\t');
});
+149
View File
@@ -0,0 +1,149 @@
/**
* Wrapper for the notifu 1.6 (http://www.paralint.com/projects/notifu/)
Usage
/t <value> The type of message to display values are:
info The message is an informational message
warn The message is an warning message
error The message is an error message
/d <value> The number of milliseconds to display (omit or 0 for infinit)
/p <value> The title (or prompt) of the ballon
/m <value> The message text
/i <value> Specify an icon to use ("parent" uses the icon of the parent process)
/e Enable ballon tips in the registry (for this user only)
/q Do not play a sound when the tooltip is displayed
/w Show the tooltip even if the user is in the quiet period that follows his very first login (Windows 7 and up)
/xp Use IUserNotification interface event when IUserNotification2 is available
// Kill codes:
2 = Timeout
3 = Clicked
4 = Closed or faded out
*/
var path = require('path'),
notifier = path.resolve(__dirname, '../vendor/notifu/notifu'),
utils = require('../lib/utils'),
checkGrowl = require('../lib/checkGrowl'),
Toaster = require('./toaster'),
Growl = require('./growl'),
os = require('os'),
cloneDeep = require('lodash.clonedeep');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var hasGrowl = void 0;
module.exports = WindowsBalloon;
function WindowsBalloon (options) {
options = cloneDeep(options || {});
if (!(this instanceof WindowsBalloon)) {
return new WindowsBalloon(options);
}
this.options = options;
EventEmitter.call(this);
}
util.inherits(WindowsBalloon, EventEmitter);
WindowsBalloon.prototype.notify = function (options, callback) {
var fallback, notifierOptions = this.options;
options = cloneDeep(options || {});
callback = callback || function () {};
if (typeof options === 'string') options = {
title: 'node-notifier',
message: options
};
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
if (data === 'activate') {
return 'click';
}
if (data === 'timeout') {
return 'timeout';
}
return false;
});
if (!!this.options.withFallback && utils.isWin8()) {
fallback = fallback || new Toaster(notifierOptions);
return fallback.notify(options, callback);
}
if (!!this.options.withFallback && (!utils.isLessThanWin8() || hasGrowl === true)) {
fallback = fallback || new Growl(notifierOptions);
return fallback.notify(options, callback);
}
if (!this.options.withFallback || hasGrowl === false) {
doNotification(options, notifierOptions, actionJackedCallback);
return this;
}
checkGrowl(notifierOptions, function (hasGrowlResult) {
hasGrowl = hasGrowlResult;
if (hasGrowl) {
fallback = fallback || new Growl(notifierOptions);
return fallback.notify(options, callback);
}
doNotification(options, notifierOptions, actionJackedCallback);
});
return this;
};
var allowedArguments = ["t", "d", "p", "m", "i", "e", "q", "w", "xp"];
function doNotification (options, notifierOptions, callback) {
var is64Bit = os.arch() === 'x64';
options = options || {};
options = utils.mapToNotifu(options);
options.p = options.p || 'Node Notification:';
var fullNotifierPath = notifier + (is64Bit ? '64' : '') + '.exe';
var localNotifier = notifierOptions.customPath || fullNotifierPath;
if (!options.m) {
callback(new Error('Message is required.'));
return this;
}
var argsList = utils.constructArgumentList(options, {
wrapper: '',
noEscape: true,
explicitTrue: true,
allowedArguments: allowedArguments
});
if (!!options.wait) {
return utils.fileCommand(localNotifier, argsList, function (error, data) {
var action = fromErrorCodeToAction(error.code);
if (action === 'error') return callback(error, data);
return callback(null, action);
});
}
utils.immediateFileCommand(localNotifier, argsList, callback);
}
function fromErrorCodeToAction (errorCode) {
switch (errorCode) {
case 2:
return 'timeout';
case 3:
case 6:
case 7:
return 'activate';
case 4:
return 'close';
default:
return 'error';
}
}
+74
View File
@@ -0,0 +1,74 @@
/**
* Wrapper for the growly module
*/
var utils = require('../lib/utils'),
checkGrowl = require('../lib/checkGrowl'),
growly = require('growly'),
cloneDeep = require('lodash.clonedeep');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var errorMessageNotFound = 'Couldn\'t connect to growl (might be used as a fallback). Make sure it is running';
module.exports = Growl;
var hasGrowl = void 0;
function Growl (options) {
options = cloneDeep(options || {});
if (!(this instanceof Growl)) {
return new Growl(options);
}
growly.appname = options.name || 'Node';
this.options = options;
EventEmitter.call(this);
}
util.inherits(Growl, EventEmitter);
Growl.prototype.notify = function (options, callback) {
growly.setHost(this.options.host, this.options.port);
options = cloneDeep(options || {});
if (typeof options === 'string') options = {
title: 'node-notifier',
message: options
};
callback = utils.actionJackerDecorator(this, options, callback, function (data) {
if (data === 'click') {
return 'click';
}
if (data === 'timedout') {
return 'timeout';
}
return false;
});
options = utils.mapToGrowl(options);
if (!options.message) {
callback(new Error('Message is required.'));
return this;
}
options.title = options.title || 'Node Notification:';
if (hasGrowl || !!options.wait) {
var localCallback = !!options.wait ? callback : function () {};
growly.notify(options.message, options, localCallback);
if (!options.wait) callback();
return this;
}
checkGrowl(growly, function (didHaveGrowl) {
hasGrowl = didHaveGrowl;
if (!didHaveGrowl) return callback(new Error(errorMessageNotFound));
growly.notify(options.message, options);
callback();
});
return this;
};
+81
View File
@@ -0,0 +1,81 @@
/**
* A Node.js wrapper for terminal-notify (with fallback).
*/
var path = require('path'),
notifier = path.join(__dirname, '../vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier'),
utils = require('../lib/utils'),
Growl = require('./growl'),
cloneDeep = require('lodash.clonedeep');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var errorMessageOsX = 'You need Mac OS X 10.8 or above to use NotificationCenter,' +
' or use Growl fallback with constructor option {withFallback: true}.';
module.exports = NotificationCenter;
function NotificationCenter (options) {
options = cloneDeep(options || {});
if (!(this instanceof NotificationCenter)) {
return new NotificationCenter(options);
}
this.options = options;
EventEmitter.call(this);
}
util.inherits(NotificationCenter, EventEmitter);
var activeId = null;
NotificationCenter.prototype.notify = function (options, callback) {
var fallbackNotifier = null, id = identificator();
options = cloneDeep(options || {});
activeId = id;
if (typeof options === 'string') options = {
title: 'node-notifier',
message: options
};
callback = callback || function () {};
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
if (activeId !== id) return false;
if (data === 'activate') {
return 'click';
}
if (data === 'timeout') {
return 'timeout';
}
return false;
});
options = utils.mapToMac(options);
if (!!options.wait) {
options.wait = 'YES';
}
if (!options.message && !options.group && !options.list && !options.remove) {
callback(new Error('Message, group, remove or list property is required.'));
return this;
}
var argsList = utils.constructArgumentList(options);
if(utils.isMountainLion()) {
utils.fileCommand(this.options.customPath || notifier, argsList, actionJackedCallback);
return this;
}
if (fallbackNotifier || !!this.options.withFallback) {
fallbackNotifier = fallbackNotifier || new Growl(this.options);
return fallbackNotifier.notify(options, callback);
}
callback(new Error(errorMessageOsX));
return this;
};
function identificator () {
return { _ref: 'val' };
}
+93
View File
@@ -0,0 +1,93 @@
/**
* Node.js wrapper for "notify-send".
*/
var os = require('os'),
which = require('which'),
utils = require('../lib/utils'),
cloneDeep = require('lodash.clonedeep');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var notifier = 'notify-send', hasNotifier = void 0;
module.exports = NotifySend;
function NotifySend (options) {
options = cloneDeep(options || {});
if (!(this instanceof NotifySend)) {
return new NotifySend(options);
}
this.options = options;
EventEmitter.call(this);
}
util.inherits(NotifySend, EventEmitter);
NotifySend.prototype.notify = function (options, callback) {
options = cloneDeep(options || {});
callback = callback || function () {};
if (typeof options === 'string') options = {
title: 'node-notifier',
message: options
};
if (!options.message) {
callback(new Error('Message is required.'));
return this;
}
if (os.type() !== 'Linux') {
callback(new Error('Only supported on Linux systems'));
return this;
}
if (hasNotifier === false) {
callback(new Error('notify-send must be installed on the system.'));
return this;
}
if (hasNotifier || !!this.options.suppressOsdCheck) {
doNotification(options, callback);
return this;
}
try {
hasNotifier = !!which.sync(notifier);
doNotification(options, callback);
} catch (err) {
hasNotifier = false;
return callback(err);
};
return this;
};
var allowedArguments = [
"urgency",
"expire-time",
"icon",
"category",
"hint"
];
function doNotification (options, callback) {
var initial, argsList;
options = utils.mapToNotifySend(options);
options.title = options.title || 'Node Notification:';
initial = [options.title, options.message];
delete options.title;
delete options.message;
argsList = utils.constructArgumentList(options, {
initial: initial,
keyExtra: '-',
allowedArguments: allowedArguments
});
utils.command(notifier, argsList, callback);
}
+67
View File
@@ -0,0 +1,67 @@
/**
* Wrapper for the toaster (https://github.com/nels-o/toaster)
*/
var path = require('path'),
notifier = path.resolve(__dirname, '../vendor/toaster/toast.exe'),
utils = require('../lib/utils'),
Balloon = require('./balloon'),
cloneDeep = require('lodash.clonedeep');
var EventEmitter = require('events').EventEmitter;
var util = require('util');
var fallback = void 0;
module.exports = WindowsToaster;
function WindowsToaster (options) {
options = cloneDeep(options || {});
if (!(this instanceof WindowsToaster)) {
return new WindowsToaster(options);
}
this.options = options;
EventEmitter.call(this);
}
util.inherits(WindowsToaster, EventEmitter);
WindowsToaster.prototype.notify = function (options, callback) {
options = cloneDeep(options || {});
callback = callback || function () {};
if (typeof options === 'string') options = {
title: 'node-notifier',
message: options
};
var actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
if (data === 'activate') {
return 'click';
}
if (data === 'timeout') {
return 'timeout';
}
return false;
});
options.title = options.title || 'Node Notification:';
if (!options.message) {
callback(new Error('Message is required.'));
return this;
}
if (!utils.isWin8() && !!this.options.withFallback) {
fallback = fallback || new Balloon(this.options);
return fallback.notify(options, callback);
}
options = utils.mapToWin8(options);
var argsList = utils.constructArgumentList(options, {
wrapper: '',
noEscape: true
});
utils.fileCommand(this.options.customPath || notifier, argsList, actionJackedCallback);
return this;
};
+113
View File
@@ -0,0 +1,113 @@
{
"_args": [
[
{
"raw": "node-notifier@^4.1.0",
"scope": null,
"escapedName": "node-notifier",
"name": "node-notifier",
"rawSpec": "^4.1.0",
"spec": ">=4.1.0 <5.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\webpack-notifier"
]
],
"_from": "node-notifier@>=4.1.0 <5.0.0",
"_id": "node-notifier@4.6.1",
"_inCache": true,
"_location": "/node-notifier",
"_nodeVersion": "6.3.1",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/node-notifier-4.6.1.tgz_1471811837812_0.47649690927937627"
},
"_npmUser": {
"name": "mikaelb",
"email": "mikaelbre@gmail.com"
},
"_npmVersion": "3.10.3",
"_phantomChildren": {
"lodash._baseclone": "3.3.0",
"lodash._bindcallback": "3.0.1"
},
"_requested": {
"raw": "node-notifier@^4.1.0",
"scope": null,
"escapedName": "node-notifier",
"name": "node-notifier",
"rawSpec": "^4.1.0",
"spec": ">=4.1.0 <5.0.0",
"type": "range"
},
"_requiredBy": [
"/webpack-notifier"
],
"_resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-4.6.1.tgz",
"_shasum": "056d14244f3dcc1ceadfe68af9cff0c5473a33f3",
"_shrinkwrap": null,
"_spec": "node-notifier@^4.1.0",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\webpack-notifier",
"author": {
"name": "Mikael Brevik"
},
"bin": {
"notify": "./bin.js"
},
"bugs": {
"url": "https://github.com/mikaelbr/node-notifier/issues"
},
"dependencies": {
"cli-usage": "^0.1.1",
"growly": "^1.2.0",
"lodash.clonedeep": "^3.0.0",
"minimist": "^1.1.1",
"semver": "^5.1.0",
"shellwords": "^0.1.0",
"which": "^1.0.5"
},
"description": "A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)",
"devDependencies": {
"mocha": "^3.0.0",
"should": "^4.0.4"
},
"directories": {
"example": "example"
},
"dist": {
"shasum": "056d14244f3dcc1ceadfe68af9cff0c5473a33f3",
"tarball": "https://registry.npmjs.org/node-notifier/-/node-notifier-4.6.1.tgz"
},
"gitHead": "0dc7ea4dd5bcb9584e9dfda3b69e6f3bf2379968",
"homepage": "https://github.com/mikaelbr/node-notifier#readme",
"keywords": [
"notification center",
"mac os x 10.8",
"notify",
"terminal-notifier",
"notify-send",
"growl",
"windows 8 notification",
"toaster",
"notification"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "mikaelb",
"email": "mikaelbre@gmail.com"
}
],
"name": "node-notifier",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/mikaelbr/node-notifier.git"
},
"scripts": {
"test": "mocha -R spec"
},
"version": "4.6.1"
}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>15A278b</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>terminal-notifier</string>
<key>CFBundleIconFile</key>
<string>Terminal</string>
<key>CFBundleIdentifier</key>
<string>nl.superalloy.oss.terminal-notifier</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>terminal-notifier</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.6.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>14</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>7D1014</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>15E60</string>
<key>DTSDKName</key>
<string>macosx10.11</string>
<key>DTXcode</key>
<string>0731</string>
<key>DTXcodeBuild</key>
<string>7D1014</string>
<key>LSMinimumSystemVersion</key>
<string>10.8</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012-2015 Eloy Durán, Julien Blanchard. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
@@ -0,0 +1 @@
APPL????
@@ -0,0 +1,29 @@
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw9840\paperh8400
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs24 \cf0 Engineering:
\b0 \
Some people\
\
\b Human Interface Design:
\b0 \
Some other people\
\
\b Testing:
\b0 \
Hopefully not nobody\
\
\b Documentation:
\b0 \
Whoever\
\
\b With special thanks to:
\b0 \
Mom\
}
Binary file not shown.
Binary file not shown.
Binary file not shown.