opencollective-postinstall
Advanced tools
Comparing version 1.0.16 to 1.0.17
#!/usr/bin/env node | ||
const collective_url = process.env.npm_package_collective_url; | ||
const collective_logo = process.env.npm_package_collective_logo; | ||
const lifecycle_event = process.env.npm_lifecycle_event; | ||
const utils = require('../lib/utils'); | ||
/** | ||
* If we are not on a fancy TTY, just show a barebone message | ||
* without fancy emoji, centering, fetching data, etc. | ||
*/ | ||
if(!utils.isFancyEnvironment()) { | ||
console.log(""); | ||
console.log(` *** Thank you for using ${process.env.npm_package_name}! ***`); | ||
console.log(""); | ||
console.log(`Please consider donating to our open collective`); | ||
console.log(` to help us maintain this package.`); | ||
console.log(""); | ||
console.log(` ${collective_url}/donate`); | ||
console.log(""); | ||
console.log(` ***`); | ||
console.log(""); | ||
process.exit(0); | ||
} | ||
const debug = utils.debug; | ||
const fs = require('fs'); | ||
const utils = require('../lib/utils'); | ||
const fetchData = require('../lib/fetchData'); | ||
const print = require('../lib/print'); | ||
const debug = utils.debug; | ||
const padding = utils.padding; | ||
@@ -15,6 +38,2 @@ const fetchStats = fetchData.fetchStats; | ||
const collective_url = process.env.npm_package_collective_url; | ||
const collective_logo = process.env.npm_package_collective_logo; | ||
const lifecycle_event = process.env.npm_lifecycle_event; | ||
function init() { | ||
@@ -21,0 +40,0 @@ const promises = []; |
#!/usr/bin/env node | ||
const utils = require('../lib/utils'); | ||
const debug = utils.debug; | ||
// Only run in development environment | ||
if (process.env.NODE_ENV && process.env.NODE_ENV !== 'dev' && process.env.NODE_ENV !== 'development') { | ||
debug("Wrong environment", process.env.NODE_ENV); | ||
if (!utils.isDevEnvironment()) { | ||
process.exit(0); | ||
} | ||
const debug = utils.debug; | ||
// In some CI environment, NODE_ENV might not be defined. | ||
@@ -122,3 +120,4 @@ // We exit if `inquirer` module is not installed | ||
} | ||
var postinstall = "./node_modules/.bin/opencollective-postinstall || exit 0"; | ||
var postinstall = "./node_modules/.bin/opencollective-postinstall || exit"; | ||
package.scripts = package.scripts || {}; | ||
if (package.scripts.postinstall && package.scripts.postinstall.indexOf(postinstall) === -1) { | ||
@@ -125,0 +124,0 @@ package.scripts.postinstall = `${package.scripts.postinstall} && ${postinstall}`; |
@@ -22,2 +22,4 @@ const execSync = require('child_process').execSync; | ||
donate_url += (npm_config_user_agent.match(/yarn/)) ? '/yarn' : '/npm'; | ||
} else { | ||
donate_url += '/donate'; | ||
} | ||
@@ -69,3 +71,3 @@ return donate_url; | ||
print(`Thanks for installing ${package_name} ${emoji('🙏')}.`, { color: 'yellow' }); | ||
print(`Thanks for installing ${package_name} ${emoji('🙏')}`, { color: 'yellow' }); | ||
print(`Please consider donating to our open collective`, { color: 'dim' }); | ||
@@ -72,0 +74,0 @@ print(`to help us maintain this package.`, { color: 'dim' }); |
@@ -9,2 +9,10 @@ const chalk = require('chalk'); | ||
const isDevEnvironment = function() { | ||
return (!process.env.NODE_ENV || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development'); | ||
} | ||
const isFancyEnvironment = function() { | ||
return (isDevEnvironment() && process.stdout.isTTY && process.platform !== 'win32'); | ||
} | ||
const padding = function(length) { | ||
@@ -31,2 +39,4 @@ var padding = ''; | ||
module.exports = { | ||
isDevEnvironment, | ||
isFancyEnvironment, | ||
debug, | ||
@@ -33,0 +43,0 @@ padding, |
{ | ||
"name": "opencollective-postinstall", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "Prompt users to donate after they install your node module with npm install", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
21821
385