Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
next(new Error('Feed url was not supplied'))
return this
}
// Check deprecations
if (feed.checkReponse) {
next(new Error('Feed checkResponse option is deprecated for check'))
return this
}
// Ensure optional
feed = this.prepareFeed(feed)
// Plugins
const plugins = {}
if (typeChecker.isString(feed.plugins)) {
feed.plugins = feed.plugins.split(' ')
}
if (typeChecker.isArray(feed.plugins)) {
for (let i = 0; i < feed.plugins.length; ++i) {
const name = feed.plugins[i]
try {
plugins[name] = require('./plugins/' + name)
} catch (err) {
next(err)
return this
}
}
}
// Generators
function generateParser(name, method, opts, complete) {
}
// Validate keywords field
if (isString(this.mergedPackageData.keywords)) {
next(new Error('projectz: keywords field must be array instead of CSV'))
return this
}
// Validate sponsors array
if (this.mergedPackageData.sponsor) {
next(
new Error('projectz: sponsor field is deprecated, use sponsors field')
)
return this
}
if (isString(this.mergedPackageData.sponsors)) {
next(new Error('projectz: sponsors field must be array instead of CSV'))
return this
}
// Validate maintainers array
if (this.mergedPackageData.maintainer) {
next(
new Error(
'projectz: maintainer field is deprecated, use maintainers field'
)
)
return this
}
if (isString(this.mergedPackageData.maintainers)) {
next(
new Error('projectz: maintainers field must be array instead of CSV')
}
// Raw
else {
parseResponse = function(opts, parseComplete) {
parseComplete()
}
}
// ------------------------------
// Checker
let checkResponse = null
// Specific
if (typeChecker.isString(feed.check)) {
// Exists
if (
typeChecker.isFunction(plugins[feed.check] && plugins[feed.check].check)
) {
checkResponse = generateChecker.bind(
null,
feed.check,
plugins[feed.check].check
)
}
// Missing
else {
next(new Error('Invalid check value: ' + feed.check))
return this
}
}
if (isString(this.mergedPackageData.sponsors)) {
next(new Error('projectz: sponsors field must be array instead of CSV'))
return this
}
// Validate maintainers array
if (this.mergedPackageData.maintainer) {
next(
new Error(
'projectz: maintainer field is deprecated, use maintainers field'
)
)
return this
}
if (isString(this.mergedPackageData.maintainers)) {
next(
new Error('projectz: maintainers field must be array instead of CSV')
)
return this
}
// Validate license SPDX string
if (isObject(this.mergedPackageData.license)) {
next(
new Error(
'projectz: license field must now be a valid SPDX string: https://docs.npmjs.com/files/package.json#license'
)
)
return this
}
if (isObject(this.mergedPackageData.licenses)) {
}
me.log(
'debug',
`Feedr check [${feed.url}] with ${name} attempt, success`
)
complete(null, data)
})
}
// ------------------------------
// Parser
let parseResponse = null
// Specific
if (typeChecker.isString(feed.parse)) {
// Exists
if (
typeChecker.isFunction(plugins[feed.parse] && plugins[feed.parse].parse)
) {
parseResponse = generateParser.bind(
null,
feed.parse,
plugins[feed.parse].parse
)
}
// Missing
else {
next(new Error('Invalid parse value: ' + feed.parse))
return this
}
// ----------------------------------
// Validation
// Validate badges field
if (this.mergedPackageData.badges && !this.mergedPackageData.badges.list) {
next(
new Error(
'projectz: badges field must now be in the format of: {list: [], config: {}}\nSee https://github.com/bevry/badges for details.'
)
)
return this
}
// Validate keywords field
if (isString(this.mergedPackageData.keywords)) {
next(new Error('projectz: keywords field must be array instead of CSV'))
return this
}
// Validate sponsors array
if (this.mergedPackageData.sponsor) {
next(
new Error('projectz: sponsor field is deprecated, use sponsors field')
)
return this
}
if (isString(this.mergedPackageData.sponsors)) {
next(new Error('projectz: sponsors field must be array instead of CSV'))
return this
}
tasks.addTask(function(complete) {
// Prepare
if (typeChecker.isString(feed)) {
feed = { url: feed }
}
feeds[index] = feed = extendr.deep({}, defaultfeed, feed)
// Read
me.readFeed(feed, function(err, data) {
// Handle
if (err) {
me.log(
'warn',
`Feedr failed to fetch [${feed.url}] to [${feed.path}]`,
err.stack
)
failures.push(err)
} else {
results[index] = data
args.forEach(function(arg) {
if (typeChecker.isString(arg)) {
url = arg
} else if (typeChecker.isFunction(arg)) {
next = arg
} else if (typeChecker.isPlainObject(arg)) {
feed = arg
}
})