mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
Fixed code style
This commit is contained in:
parent
adb40fc5f4
commit
fee0864ba1
1 changed files with 14 additions and 14 deletions
|
@ -4,9 +4,9 @@ var Logger = require('./logger')
|
|||
|
||||
var handleNotify = function(metadata, notifyEntry) {
|
||||
var regex
|
||||
if(metadata.name && notifyEntry.packagePattern) {
|
||||
if (metadata.name && notifyEntry.packagePattern) {
|
||||
regex = new RegExp(notifyEntry.packagePattern, notifyEntry.packagePatternFlags || '')
|
||||
if(!regex.test(metadata.name)) {
|
||||
if (!regex.test(metadata.name)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -19,47 +19,47 @@ var handleNotify = function(metadata, notifyEntry) {
|
|||
}
|
||||
|
||||
// provides fallback support, it's accept an Object {} and Array of {}
|
||||
if ( notifyEntry.headers && Array.isArray(notifyEntry.headers) ) {
|
||||
var header = {};
|
||||
if (notifyEntry.headers && Array.isArray(notifyEntry.headers)) {
|
||||
var header = {}
|
||||
notifyEntry.headers.map(function(item) {
|
||||
if (Object.is(item, item)) {
|
||||
for (var key in item) {
|
||||
header[key] = item[key];
|
||||
header[key] = item[key]
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
options.headers = header;
|
||||
} else if (Object.is(notifyEntry.headers, notifyEntry.headers)) {
|
||||
options.headers = notifyEntry.headers;
|
||||
options.headers = notifyEntry.headers
|
||||
}
|
||||
|
||||
options.method = notifyEntry.method
|
||||
|
||||
if(notifyEntry.endpoint) {
|
||||
if ( notifyEntry.endpoint ) {
|
||||
options.url = notifyEntry.endpoint
|
||||
}
|
||||
|
||||
request(options, function(err, response, body) {
|
||||
if (err) {
|
||||
Logger.logger.error( { err: err }, ' notify error: @{err.message}' );
|
||||
Logger.logger.error( { err: err }, ' notify error: @{err.message}' )
|
||||
} else {
|
||||
Logger.logger.info({ content: content}, 'A notification has been shipped: @{content}')
|
||||
if (body) {
|
||||
Logger.logger.debug( { body: body }, ' body: @{body}' );
|
||||
Logger.logger.debug( { body: body }, ' body: @{body}' )
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.notify = function(metadata, config) {
|
||||
|
||||
if (config.notify) {
|
||||
if(config.notify.content) {
|
||||
if (config.notify.content) {
|
||||
handleNotify(metadata, config.notify)
|
||||
}
|
||||
else {
|
||||
for(var key in config.notify) {
|
||||
if(config.notify.hasOwnProperty(key)) {
|
||||
for (var key in config.notify) {
|
||||
if (config.notify.hasOwnProperty(key)) {
|
||||
handleNotify(metadata, config.notify[key])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue