0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

Fix eslint issues, add jsdoc

This commit is contained in:
Juan Picado 2017-04-27 05:52:46 +02:00
parent 09c60e68e0
commit acfd865bb0
No known key found for this signature in database
GPG key ID: 18AC54485952D158
4 changed files with 29 additions and 8 deletions

View file

@ -1,7 +1,12 @@
'use strict';
let Path = require('path');
const Path = require('path');
/**
* Requires a module.
* @param {*} path the module's path
* @return {Object}
*/
function try_load(path) {
try {
return require(path);
@ -13,6 +18,17 @@ function try_load(path) {
}
}
/**
* Load a plugin following the rules
* - First try to load from the internal directory plugins (which will disappear soon or later).
* - A seccond attempt from node_modules, in case to have multiple match as for instance verdaccio-ldap
* and sinopia-ldap. All verdaccio prefix will have preferences.
* @param {*} config a reference of the configuration settings
* @param {*} plugin_configs
* @param {*} params a set of params to initialise the plugin
* @param {*} sanity_check callback that check the shape that should fulfill the plugin
* @return {Array} list of plugins
*/
function load_plugins(config, plugin_configs, params, sanity_check) {
let plugins = Object.keys(plugin_configs || {}).map(function(p) {
let plugin;

View file

@ -1,3 +1,5 @@
/* eslint no-invalid-this: "off" */
'use strict';
const lunr = require('lunr');

View file

@ -1,3 +1,5 @@
/* eslint prefer-rest-params: "off" */
'use strict';
// see https://secure.flickr.com/photos/girliemac/sets/72157628409467125

View file

@ -97,21 +97,23 @@ function filter_tarball_urls(pkg, req, config) {
if (!req.headers.host) {
return _url;
}
let filename = URL.parse(_url).pathname.replace(/^.*\//, '');
const filename = URL.parse(_url).pathname.replace(/^.*\//, '');
let result;
if (config.url_prefix != null) {
result = config.url_prefix.replace(/\/$/, '');
} else {
result = req.protocol + '://' + req.headers.host;
result = `${req.protocol}://${req.headers.host}`;
}
return `${result}/${pkg.name.replace(/\//g, '%2f')}/-/${filename}`;
};
for (let ver in pkg.versions) {
let dist = pkg.versions[ver].dist;
if (dist != null && dist.tarball != null) {
// dist.__verdaccio_orig_tarball = dist.tarball
dist.tarball = filter(dist.tarball);
if (Object.prototype.hasOwnProperty.call(pkg.versions, ver)) {
const dist = pkg.versions[ver].dist;
if (dist != null && dist.tarball != null) {
// dist.__verdaccio_orig_tarball = dist.tarball
dist.tarball = filter(dist.tarball);
}
}
}
return pkg;
@ -227,7 +229,6 @@ function semver_sort(array) {
*/
function normalize_dist_tags(data) {
let sorted;
if (!data['dist-tags'].latest) {
// overwrite latest with highest known version based on semver sort
sorted = module.exports.semver_sort(Object.keys(data.versions));