netlify-plugin-submit-sitemap
Advanced tools
Comparing version 0.2.2 to 0.2.3
20
index.js
@@ -8,6 +8,2 @@ const url = require('url'); | ||
const isProduction = () => { | ||
return CONTEXT === 'production'; | ||
} | ||
const providerUrls = { | ||
@@ -56,3 +52,3 @@ 'google': (sitemapUrl) => `https://www.google.com/ping?sitemap=${sitemapUrl}`, | ||
const prependScheme = (baseUrl) => { | ||
return baseUrl.match(/^[a-zA-Z]+:\/\//) | ||
return baseUrl.match(/^[a-zA-Z]+:\/\//) | ||
? baseUrl | ||
@@ -63,3 +59,3 @@ : baseUrl = `https://${baseUrl}`; | ||
module.exports = { | ||
async onSuccess({ utils, inputs }) { | ||
async onSuccess({ utils, inputs, constants }) { | ||
const { providers, baseUrl, sitemapPath } = { | ||
@@ -69,4 +65,4 @@ ...defaults, ...removeEmptyValues(inputs) | ||
// Only run on production branch | ||
if (!isProduction()) { | ||
// Only run on production builds | ||
if (constants.IS_LOCAL || CONTEXT !== 'production') { | ||
console.log(`Skip submitting sitemap to ${providers.join(', ')}, because this isn't a production build`); | ||
@@ -89,7 +85,7 @@ return; | ||
// For failed submissions, it might be better to use something like a utils.build.warn() as discussed here: | ||
// For failed submissions, it might be better to use something like a utils.build.warn() as discussed here: | ||
// https://github.com/cdeleeuwe/netlify-plugin-submit-sitemap/issues/4 | ||
// But till then, just console.log the errors and fail the plugin. | ||
// --- | ||
// For successful submissions, it's better to use utils.status.show(), but currently Netlify doesn't show | ||
// For successful submissions, it's better to use utils.status.show(), but currently Netlify doesn't show | ||
// the status in the UI yet, so also console.log() it for now | ||
@@ -112,3 +108,3 @@ // See https://github.com/cdeleeuwe/netlify-plugin-submit-sitemap/issues/5 | ||
.filter(error => error); | ||
// If there was at least 1 error, fail the plugin, but continue the build. | ||
@@ -121,2 +117,2 @@ if (errors.length > 0) { | ||
} | ||
}; | ||
}; |
{ | ||
"name": "netlify-plugin-submit-sitemap", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Automatically submit your sitemap to Google, Bing, and Yandex!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
5803
94