lightercollective
Advanced tools
Comparing version 0.2.0 to 0.3.0
74
index.js
#!/usr/bin/env node | ||
// (C) Andrea Giammarchi - @WebReflection (ISC) | ||
var path = require('path'); | ||
var json = path.resolve('./package.json'); | ||
var package = require(json); | ||
var collective = package.collective; | ||
if ( | ||
!collective || | ||
-1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) || | ||
/^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE) | ||
) { | ||
try { | ||
var json = path.resolve('./package.json'); | ||
var package = require(json); | ||
// be sure collective is there and refers to lightercollective | ||
var collective = ( | ||
(package.dependencies || {}).lightercollective || | ||
(package.devDependencies || {}).lightercollective | ||
) && package.collective; | ||
if ( | ||
!collective || | ||
-1 < ['silent', 'error', 'warn'].indexOf(process.env.npm_config_loglevel) || | ||
/^(?:1|true|yes|y)$/i.test(process.env.DISABLE_OPENCOLLECTIVE) | ||
) { | ||
throw 0; | ||
} | ||
if (collective.logo) { | ||
if (/^(https?):/.test(collective.logo)) | ||
require(RegExp.$1) | ||
.get(collective.logo, function (response) { | ||
if (response.statusCode === 200) { | ||
response.setEncoding('utf8'); | ||
var data = []; | ||
response.on('data', function (chunk) { data.push(chunk); }); | ||
response.on('end', function () { showLogo(data.join('')) }); | ||
} | ||
else showLogo(null); | ||
}) | ||
.on('error', showLogo); | ||
else | ||
require('fs').readFile( | ||
path.resolve(path.dirname(json), collective.logo), | ||
function (err, data) { | ||
showLogo(err ? null : data.toString()) | ||
} | ||
) | ||
} | ||
else showLogo(null); | ||
} catch(o_O) { | ||
process.exit(0); | ||
} | ||
if (collective.logo) { | ||
if (/^(https?):/.test(collective.logo)) | ||
require(RegExp.$1) | ||
.get(collective.logo, function (response) { | ||
if (response.statusCode === 200) { | ||
response.setEncoding('utf8'); | ||
var data = []; | ||
response.on('data', function (chunk) { data.push(chunk); }); | ||
response.on('end', function () { showLogo(data.join('')) }); | ||
} | ||
else showLogo(null); | ||
}) | ||
.on('error', showLogo); | ||
else | ||
require('fs').readFile( | ||
path.resolve(path.dirname(json), collective.logo), | ||
function (err, data) { | ||
showLogo(err ? null : data.toString()) | ||
} | ||
) | ||
} | ||
else showLogo(null); | ||
function showLogo(data) { | ||
@@ -48,4 +56,4 @@ var logo = typeof data === 'string' ? data : ''; | ||
console.log(''); | ||
console.log('Please consider donating to our open collective'); | ||
console.log(' to help us maintain this package.'); | ||
console.log(' Please consider donating to our open collective'); | ||
console.log(' to help us maintain this package.'); | ||
console.log(''); | ||
@@ -57,2 +65,2 @@ console.log(' ' + collective.url + '/donate'); | ||
process.exit(0); | ||
} | ||
} |
{ | ||
"name": "lightercollective", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "a basic postinstall only binary based on package.json collective info", | ||
@@ -5,0 +5,0 @@ "bin": "./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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
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
5662
6
62
1