1
1
#! /usr/bin/env node
2
- const fs = require ( 'fs' ) ;
2
+ /* eslint consistent-return:0*/
3
+
3
4
const webPush = require ( '../src/index.js' ) ;
4
5
5
6
const printUsageDetails = ( ) => {
6
- const spc = ' ' ;
7
-
8
7
const actions = [
9
8
{
10
9
name : 'send-notification' ,
@@ -45,7 +44,7 @@ const generateVapidKeys = returnJson => {
45
44
if ( returnJson ) {
46
45
outputText = JSON . stringify ( vapidKeys ) ;
47
46
} else {
48
- const outputLine = '\n=======================================\n'
47
+ const outputLine = '\n=======================================\n' ;
49
48
outputText = outputLine + '\n' +
50
49
'Public Key:\n' + vapidKeys . publicKey + '\n\n' +
51
50
'Private Key:\n' + vapidKeys . privateKey + '\n' +
@@ -62,31 +61,31 @@ const sendNotification = args => {
62
61
}
63
62
64
63
const subscription = {
65
- endpoint : argv . endpoint ,
64
+ endpoint : args . endpoint ,
66
65
keys : {
67
- p256dh : argv . key || null ,
68
- auth : argv . auth || null
66
+ p256dh : args . key || null ,
67
+ auth : args . auth || null
69
68
}
70
69
} ;
71
70
72
- const payload = argv . payload || null ;
71
+ const payload = args . payload || null ;
73
72
74
73
const options = { } ;
75
74
76
- if ( argv . ttl ) {
77
- options . TTL = argv . ttl ;
75
+ if ( args . ttl ) {
76
+ options . TTL = args . ttl ;
78
77
}
79
78
80
79
if ( argv [ 'vapid-subject' ] || argv [ 'vapid-pubkey' ] || argv [ 'vapid-pvtkey' ] ) {
81
80
options . vapidDetails = {
82
- subject : argv [ 'vapid-subject' ] || null ,
83
- publicKey : argv [ 'vapid-pubkey' ] || null ,
84
- privateKey : argv [ 'vapid-pvtkey' ] || null
85
- }
81
+ subject : args [ 'vapid-subject' ] || null ,
82
+ publicKey : args [ 'vapid-pubkey' ] || null ,
83
+ privateKey : args [ 'vapid-pvtkey' ] || null
84
+ } ;
86
85
}
87
86
88
- if ( argv [ 'gcm-api-key' ] ) {
89
- options . gcmAPIKey = argv [ 'gcm-api-key' ] ;
87
+ if ( args [ 'gcm-api-key' ] ) {
88
+ options . gcmAPIKey = args [ 'gcm-api-key' ] ;
90
89
}
91
90
92
91
webPush . sendNotification ( subscription , payload , options )
0 commit comments