Skip to content

Commit

Permalink
fix: only output greeting message on first install (#40)
Browse files Browse the repository at this point in the history
* fix: only output disabled for machine message once
  • Loading branch information
web-padawan authored and Artur- committed Aug 1, 2019
1 parent c798a71 commit 4b0ecf6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions check.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
var fs = require('fs');

const disabledForMachine = process.env.npm_package_config_disabled;
const greetingLogged = process.env.npm_package_config_greeting_logged;
const optoutLogged = process.env.npm_package_config_optout_logged;

let disabledForProject = false;

if (fs.existsSync("../../../package.json")) {
Expand All @@ -12,11 +15,11 @@ if (fs.existsSync("../../../package.json")) {

if (disabledForMachine || disabledForProject) {
if (disabledForMachine) {
console.log(`
!optoutLogged && console.log(`
You have disabled Vaadin development time usage statistics collection. To re-enable, run:
npm explore @vaadin/vaadin-usage-statistics -- npm run enable
For more details, see https://github.com/vaadin/vaadin-usage-statistics
`);
`);
} else {
console.log(`
You have disabled Vaadin development time usage statistics collection. To re-enable, remove:
Expand All @@ -33,7 +36,7 @@ if (disabledForMachine || disabledForProject) {
throw err;
}
} else {
console.log(`
!greetingLogged && console.log(`
Vaadin collects development time usage statistics to improve this product. To opt-out, either run:
npm explore @vaadin/vaadin-usage-statistics -- npm run disable
to store disable statistics for the machine, or add
Expand Down
2 changes: 1 addition & 1 deletion magi-p3-post.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"\"license\": \"Apache-2.0\","
],
"to": [
"\"license\": \"Apache-2.0\",\n\"scripts\": {\n\"postinstall\": \"node check.js\",\n\"disable\": \"npm config set @vaadin/vaadin-usage-statistics:disabled true && npm run postinstall\",\n\"enable\": \"npm config set @vaadin/vaadin-usage-statistics:disabled false && npm run postinstall\"\n},"
"\"license\": \"Apache-2.0\",\n\"scripts\": {\n\"postinstall\": \"node check.js && npm config set @vaadin/vaadin-usage-statistics:greeting-logged true\",\n\"disable\": \"npm config set @vaadin/vaadin-usage-statistics:disabled true && npm run postinstall && npm config set @vaadin/vaadin-usage-statistics:optout-logged true\",\n\"enable\": \"npm config set @vaadin/vaadin-usage-statistics:disabled false && npm config set @vaadin/vaadin-usage-statistics:greeting-logged false && npm config set @vaadin/vaadin-usage-statistics:optout-logged false && npm run postinstall\"\n},"
]
}

0 comments on commit 4b0ecf6

Please sign in to comment.