opencollective-postinstall
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -77,3 +77,3 @@ #!/usr/bin/env node | ||
default: package.name, | ||
validate: (str) => { | ||
validate: function(str) { | ||
if(str.match(/^[a-zA-Z\-0-9]+$/)) return true; | ||
@@ -87,8 +87,10 @@ else return "Please enter a valid slug (e.g. https://opencollective.com/webpack)"; | ||
message: "What logo should we use?", | ||
choices: (answers) => [ | ||
{ name: "Open Collective logo (see above)", value: "https://opencollective.com/opencollective/logo.txt" }, | ||
{ name: "The logo of your Collective (https://opencollective.com/" + answers.collectiveSlug + "/logo.txt)", value: "https://opencollective.com/" + answers.collectiveSlug + "/logo.txt" }, | ||
{ name: "Custom URL", value: "custom"}, | ||
{ name: "No logo", value: null } | ||
] | ||
choices: function(answers) { | ||
return [ | ||
{ name: "Open Collective logo (see above)", value: "https://opencollective.com/opencollective/logo.txt" }, | ||
{ name: "The logo of your Collective (https://opencollective.com/" + answers.collectiveSlug + "/logo.txt)", value: "https://opencollective.com/" + answers.collectiveSlug + "/logo.txt" }, | ||
{ name: "Custom URL", value: "custom"}, | ||
{ name: "No logo", value: null } | ||
]; | ||
} | ||
}, | ||
@@ -99,8 +101,12 @@ { | ||
message: "URL of your logo in ASCII art", | ||
default: (answers) => "https://opencollective.com/" + answers.collectiveSlug + "/logo.txt", | ||
validate: (str) => { | ||
default: function(answers) { | ||
"https://opencollective.com/" + answers.collectiveSlug + "/logo.txt" | ||
}, | ||
validate: function(str) { | ||
if(str.match(/^https?:\/\/[^\/]+\/.+$/)) return true; | ||
else return "Please enter a valid url (e.g. https://opencollective.com/webpack/logo.txt)"; | ||
}, | ||
when: (answers) => answers.showLogo === "custom" | ||
when: function(answers) { | ||
return (answers.showLogo === "custom"); | ||
} | ||
} | ||
@@ -113,3 +119,3 @@ ]; | ||
console.log(""); | ||
return inquirer.prompt(questions).catch(e => { | ||
return inquirer.prompt(questions).catch(function(e) { | ||
debug("Error while running the prompt", e); | ||
@@ -160,3 +166,3 @@ process.exit(0); | ||
var firstBadgeDetected = false; | ||
lines.forEach(line => { | ||
lines.forEach(function(line) { | ||
if (!firstBadgeDetected && (line.match(/badge.svg/) || line.match(/img.shields.io/))) { | ||
@@ -169,3 +175,3 @@ firstBadgeDetected = true; | ||
return fetchBanner(collectiveSlug).then((banner) => { | ||
return fetchBanner(collectiveSlug).then(function(banner) { | ||
newLines.push(banner); | ||
@@ -186,3 +192,3 @@ console.log("> Adding badges and placeholders for backers and sponsors on your README.md"); | ||
.then(ProcessAnswers) | ||
.then(() => { | ||
.then(function() { | ||
console.log("Done."); | ||
@@ -198,5 +204,5 @@ console.log(""); | ||
}) | ||
.catch(e => { | ||
.catch(function(e) { | ||
debug("Error while trying to fetch the open collective logo or running the prompt", e); | ||
process.exit(0) | ||
}); |
@@ -9,4 +9,6 @@ const utils = require('../lib/utils'); | ||
return fetch(url, { timeout: 1500 }) | ||
.then(res => res.json()) | ||
.then((json) => { | ||
.then(function(res) { | ||
return res.json(); | ||
}) | ||
.then(function(json) { | ||
return { | ||
@@ -20,3 +22,3 @@ currency: json.currency, | ||
}) | ||
.catch(e => { | ||
.catch(function(e) { | ||
debug("Error while fetching ", url); | ||
@@ -29,4 +31,6 @@ }); | ||
return fetch(url) | ||
.then(res => res.text()) | ||
.catch(e => { | ||
.then(function(res) { | ||
return res.text(); | ||
}) | ||
.catch(function(e) { | ||
debug("Error while fetching ", url); | ||
@@ -41,7 +45,7 @@ }); | ||
return fetch(logoUrl, { timeout: 1500 }) | ||
.then(res => { | ||
.then(function(res) { | ||
if (res.status === 200 && res.headers.get('content-type').match(/^text\/plain/)) return res.text(); | ||
else return ""; | ||
}) | ||
.catch(e => { | ||
.catch(function(e) { | ||
debug("Error while fetching ", logoUrl); | ||
@@ -48,0 +52,0 @@ }); |
@@ -52,3 +52,5 @@ const execSync = require('child_process').execSync; | ||
if (!logotxt) return; | ||
logotxt.split('\n').forEach((line) => print(line, { color: 'blue' })); | ||
logotxt.split('\n').forEach(function(line) { | ||
return print(line, { color: 'blue' }); | ||
}); | ||
} | ||
@@ -55,0 +57,0 @@ |
@@ -10,2 +10,4 @@ const chalk = require('chalk'); | ||
const isDevEnvironment = function() { | ||
if (process.env.OC_POSTINSTALL_TEST) return true; | ||
if (process.env.CI || process.env.CONTINUOUS_INTEGRATION) return false; | ||
return (!process.env.NODE_ENV || process.env.NODE_ENV === 'dev' || process.env.NODE_ENV === 'development'); | ||
@@ -32,3 +34,3 @@ } | ||
style: 'currency', | ||
currency, | ||
currency: currency, | ||
minimumFractionDigits : precision, | ||
@@ -40,7 +42,7 @@ maximumFractionDigits : precision | ||
module.exports = { | ||
isDevEnvironment, | ||
isFancyEnvironment, | ||
debug, | ||
padding, | ||
formatCurrency | ||
isDevEnvironment: isDevEnvironment, | ||
isFancyEnvironment: isFancyEnvironment, | ||
debug: debug, | ||
padding: padding, | ||
formatCurrency: formatCurrency | ||
}; |
{ | ||
"name": "opencollective-postinstall", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Prompt users to donate after they install your node module with npm install", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,6 +16,6 @@ var execSync = require('child_process').execSync; | ||
describe("setup.test.js", () => { | ||
describe("setup.test.js", function() { | ||
// restore the originals package.json | ||
after(() => { | ||
after(function() { | ||
fs.writeFileSync(paths.packagejson, originalPackageJSON, "utf8"); | ||
@@ -36,3 +36,2 @@ fs.writeFileSync(paths.parentpackagejson, originalParentPackageJSON, "utf8"); | ||
const proc = execSync("cross-env OC_POSTINSTALL_TEST=true npm install --save " + path.resolve(__dirname, "../"), { cwd: paths.package }); | ||
// const setup = execSync("cross-env OC_POSTINSTALL_TEST=true npm run setup", { cwd: paths.postinstallpackage }); | ||
const package = JSON.parse(fs.readFileSync(paths.packagejson, 'utf8')); | ||
@@ -39,0 +38,0 @@ expect(package.collective).to.exist; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
26656
396
16