Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Jan 21, 2021
2 parents 1e280bb + 603b842 commit 040818a
Show file tree
Hide file tree
Showing 41 changed files with 5,980 additions and 5,091 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Expand Up @@ -6,6 +6,8 @@
},
"rules": {
"space-before-function-paren": 0,
"no-control-regex": 0
"no-control-regex": 0,
"no-prototype-builtins": 0,
"comma-dangle": 0
}
}
3 changes: 2 additions & 1 deletion .prettierrc
@@ -1,4 +1,5 @@
{
"printWidth": 80,
"singleQuote": true
"singleQuote": true,
"trailingComma": "none"
}
9 changes: 3 additions & 6 deletions .travis.yml
@@ -1,8 +1,5 @@
language: node_js
node_js:
- "9"
- "8"
- "7"
- "6"
- "5"
- "4"
- 'node'
- '10'
install: npm install
233 changes: 153 additions & 80 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTE.md → CONTRIBUTING.md
Expand Up @@ -12,7 +12,7 @@ DEBUG="notifier" node index.js

```
node-notifier debug info (fileCommandJson):
[notifier path] /Users/mib/node-notifier/vendor/terminal-notifier.app/Contents/MacOS/terminal-notifier
[notifier path] /Users/mib/node-notifier/vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier
[notifier options] -message "Hello" -timeout "5" -json "true"
```

Expand Down
307 changes: 196 additions & 111 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/advanced.js
Expand Up @@ -10,7 +10,7 @@ nc.notify(
sound: 'Funk',
// case sensitive
wait: true,
appIcon: path.join(__dirname, 'coulson.jpg'),
icon: path.join(__dirname, 'coulson.jpg'),
contentImage: path.join(__dirname, 'coulson.jpg'),
open: 'file://' + path.join(__dirname, 'coulson.jpg')
},
Expand Down
9 changes: 9 additions & 0 deletions example/forceBallon.js
@@ -0,0 +1,9 @@
const notifier = require('../index');
const balloon = notifier.WindowsBalloon();
balloon
.notify({ message: 'Hello' }, function(err, data) {
console.log(err, data);
})
.on('click', function() {
console.log(arguments);
});
34 changes: 34 additions & 0 deletions example/toaster-with-actions.js
@@ -0,0 +1,34 @@
const notifier = require('../index');
const path = require('path');

notifier.notify(
{
message: 'Are you sure you want to continue?',
icon: path.join(__dirname, 'coulson.jpg'),
actions: ['OK', 'Cancel']
},
(err, data) => {
// Will also wait until notification is closed.
console.log('Waited');
console.log(JSON.stringify({ err, data }, null, '\t'));
}
);

// Built-in actions:
notifier.on('timeout', () => {
console.log('Timed out!');
});
notifier.on('activate', () => {
console.log('Clicked!');
});
notifier.on('dismissed', () => {
console.log('Dismissed!');
});

// Buttons actions (lower-case):
notifier.on('ok', () => {
console.log('"Ok" was pressed');
});
notifier.on('cancel', () => {
console.log('"Cancel" was pressed');
});
11 changes: 5 additions & 6 deletions example/toaster.js
@@ -1,24 +1,23 @@
var notifier = require('../index');
var path = require('path');
const notifier = require('../index');
const path = require('path');

notifier.notify(
{
message: 'Hello. This is a longer text\nWith "some" newlines.',
wait: true,
icon: path.join(__dirname, 'coulson.jpg'),
sound: true
},
function(err, data) {
// Will also wait until notification is closed.
console.log('Waited');
console.log(err, data);
console.log(JSON.stringify({ err, data }));
}
);

notifier.on('timeout', function() {
notifier.on('timeout', () => {
console.log('Timed out!');
});

notifier.on('click', function() {
notifier.on('click', () => {
console.log('Clicked!');
});
Binary file added example/windows-actions-example.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion index.js
Expand Up @@ -10,7 +10,9 @@ var WindowsBalloon = require('./notifiers/balloon');

var options = { withFallback: true };

switch (os.type()) {
var osType = utils.isWSL() ? 'WSL' : os.type();

switch (osType) {
case 'Linux':
module.exports = new NotifySend(options);
module.exports.Notification = NotifySend;
Expand All @@ -28,6 +30,10 @@ switch (os.type()) {
module.exports.Notification = WindowsToaster;
}
break;
case 'WSL':
module.exports = new WindowsToaster(options);
module.exports.Notification = WindowsToaster;
break;
default:
if (os.type().match(/BSD$/)) {
module.exports = new NotifySend(options);
Expand Down
4 changes: 2 additions & 2 deletions lib/checkGrowl.js
Expand Up @@ -12,12 +12,12 @@ module.exports = function(growlConfig, cb) {
var socket = net.connect(port, host);
socket.setTimeout(100);

socket.on('connect', function() {
socket.once('connect', function() {
socket.end();
cb(null, true);
});

socket.on('error', function() {
socket.once('error', function() {
socket.end();
cb(null, false);
});
Expand Down

0 comments on commit 040818a

Please sign in to comment.