update-notifier
Advanced tools
Comparing version 0.6.3 to 0.7.0
@@ -0,1 +1,2 @@ | ||
/* eslint xo/no-process-exit: "off" */ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ var updateNotifier = require('./'); |
37
index.js
'use strict'; | ||
var spawn = require('child_process').spawn; | ||
var path = require('path'); | ||
var format = require('util').format; | ||
var Configstore = require('configstore'); | ||
@@ -10,2 +11,4 @@ var chalk = require('chalk'); | ||
var boxen = require('boxen'); | ||
var xdgBasedir = require('xdg-basedir'); | ||
var ansiAlign = require('ansi-align'); | ||
var ONE_DAY = 1000 * 60 * 60 * 24; | ||
@@ -35,8 +38,19 @@ | ||
if (!this.hasCallback) { | ||
this.config = new Configstore('update-notifier-' + this.packageName, { | ||
optOut: false, | ||
// init with the current time so the first check is only | ||
// after the set interval, so not to bother users right away | ||
lastUpdateCheck: Date.now() | ||
}); | ||
try { | ||
this.config = new Configstore('update-notifier-' + this.packageName, { | ||
optOut: false, | ||
// init with the current time so the first check is only | ||
// after the set interval, so not to bother users right away | ||
lastUpdateCheck: Date.now() | ||
}); | ||
} catch (_) { | ||
// expecting error code EACCES or EPERM | ||
process.on('exit', function () { | ||
var msg = [chalk.yellow(format(' %s update check failed ', options.pkg.name))]; | ||
msg.push(format(' Try running with %s or get access ', chalk.cyan('sudo'))); | ||
msg.push(' to the local update config store via '); | ||
msg.push(chalk.cyan(format(' sudo chown -R $USER:$(id -gn $USER) %s ', xdgBasedir.config))); | ||
console.error('\n' + boxen(ansiAlign.center(msg).join('\n'))); | ||
}); | ||
} | ||
} | ||
@@ -51,3 +65,8 @@ } | ||
if (this.config.get('optOut') || 'NO_UPDATE_NOTIFIER' in process.env || process.argv.indexOf('--no-update-notifier') !== -1) { | ||
if ( | ||
!this.config || | ||
this.config.get('optOut') || | ||
'NO_UPDATE_NOTIFIER' in process.env || | ||
process.argv.indexOf('--no-update-notifier') !== -1 | ||
) { | ||
return; | ||
@@ -103,2 +122,6 @@ } | ||
}); | ||
process.on('SIGINT', function () { | ||
console.error('\n' + message); | ||
}); | ||
} else { | ||
@@ -105,0 +128,0 @@ console.error(message); |
{ | ||
"name": "update-notifier", | ||
"version": "0.6.3", | ||
"version": "0.7.0", | ||
"description": "Update notifications for your CLI app", | ||
@@ -36,3 +36,4 @@ "license": "BSD-2-Clause", | ||
"dependencies": { | ||
"boxen": "^0.3.1", | ||
"ansi-align": "^1.0.0", | ||
"boxen": "^0.5.1", | ||
"chalk": "^1.0.0", | ||
@@ -42,5 +43,7 @@ "configstore": "^2.0.0", | ||
"latest-version": "^2.0.0", | ||
"semver-diff": "^2.0.0" | ||
"semver-diff": "^2.0.0", | ||
"xdg-basedir": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"clear-require": "^1.0.1", | ||
"mocha": "*", | ||
@@ -47,0 +50,0 @@ "xo": "*" |
@@ -84,3 +84,3 @@ # update-notifier [![Build Status](https://travis-ci.org/yeoman/update-notifier.svg?branch=master)](https://travis-ci.org/yeoman/update-notifier) | ||
*Required* | ||
*Required*<br> | ||
Type: `string` | ||
@@ -90,3 +90,3 @@ | ||
*Required* | ||
*Required*<br> | ||
Type: `string` | ||
@@ -96,3 +96,3 @@ | ||
Type: `number` | ||
Type: `number`<br> | ||
Default: 1000 * 60 * 60 * 24 (1 day) | ||
@@ -104,3 +104,3 @@ | ||
Type: `function` | ||
Type: `function`<br> | ||
@@ -120,3 +120,3 @@ Passing a callback here will make it check for an update directly and report right away. Not recommended as you won't get the benefits explained in [`How`](#how). | ||
Type: `boolean` | ||
Type: `boolean`<br> | ||
Default: `true` | ||
@@ -141,3 +141,3 @@ | ||
- [Yeoman](http://yeoman.io) - Modern workflows for modern webapps | ||
- [AVA](https://github.com/sindresorhus/ava) - Simple concurrent test runner | ||
- [AVA](https://ava.li) - Simple concurrent test runner | ||
- [XO](https://github.com/sindresorhus/xo) - JavaScript happiness style linter | ||
@@ -144,0 +144,0 @@ - [Pageres](https://github.com/sindresorhus/pageres) - Capture website screenshots |
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
10130
133
8
3
+ Addedansi-align@^1.0.0
+ Addedxdg-basedir@^2.0.0
+ Addedansi-align@1.1.0(transitive)
+ Addedboxen@0.5.1(transitive)
+ Addedcamelcase@2.1.1(transitive)
+ Addedcli-boxes@1.0.0(transitive)
- Removedboxen@0.3.1(transitive)
Updatedboxen@^0.5.1