normalize terminology
This commit is contained in:
@@ -48,7 +48,7 @@ JsonFile.prototype.forEach = function(fn){
|
||||
|
||||
forOwn(this._json, fn, this);
|
||||
|
||||
return this;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ var FILE_EXTENSION = /[^.]*$/i;
|
||||
var PACKAGE_EXPECTATION = /(.*)@(.*).json$/;
|
||||
|
||||
/**
|
||||
* @constructor RegistryEntry
|
||||
* @constructor OverridesList
|
||||
*/
|
||||
|
||||
var RegistryEntryCollection = module.exports = function RegistryEntry(endpoint){
|
||||
var OverridesList = module.exports = function OverridesList(endpoint){
|
||||
|
||||
this._endpoint = endpoint;
|
||||
this._basePath = path.resolve('./package-overrides', this._endpoint);
|
||||
@@ -19,7 +19,7 @@ var RegistryEntryCollection = module.exports = function RegistryEntry(endpoint){
|
||||
|
||||
};
|
||||
|
||||
RegistryEntryCollection.prototype.forEachFile = function(fn){
|
||||
OverridesList.prototype.forEachOverrideFile = function(fn){
|
||||
|
||||
forOwn(this._files, function(file, index){
|
||||
|
||||
@@ -29,7 +29,7 @@ RegistryEntryCollection.prototype.forEachFile = function(fn){
|
||||
var fileinfo = {
|
||||
packageName: undefined,
|
||||
packageVersion: undefined,
|
||||
packageValue: undefined,
|
||||
canonicalPackageName: undefined,
|
||||
|
||||
file: file,
|
||||
endpoint: this._endpoint,
|
||||
@@ -42,7 +42,7 @@ RegistryEntryCollection.prototype.forEachFile = function(fn){
|
||||
if (match) {
|
||||
fileinfo.packageName = match[1];
|
||||
fileinfo.packageVersion = match[2];
|
||||
fileinfo.packageValue = fileinfo.endpoint + ':' + fileinfo.packageName;
|
||||
fileinfo.canonicalPackageName = fileinfo.endpoint + ':' + fileinfo.packageName;
|
||||
}
|
||||
|
||||
fn.call(this, fileinfo, index);
|
||||
@@ -3,12 +3,11 @@
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var JsonFile = require('./JsonFile');
|
||||
var PACKAGE_EXPECTATION = /^([^:\s]*):([^\s]*)$/;
|
||||
var CANONICAL_NAME_EXPECTATION = /^([^:\s]*):([^\s]*)$/;
|
||||
|
||||
/**
|
||||
* @constructor RegistryFile
|
||||
*/
|
||||
|
||||
*/
|
||||
var RegistryFile = module.exports = function RegistryFile(){
|
||||
|
||||
if( !(this instanceof RegistryFile) )
|
||||
@@ -19,30 +18,29 @@ var RegistryFile = module.exports = function RegistryFile(){
|
||||
|
||||
util.inherits(RegistryFile, JsonFile);
|
||||
|
||||
RegistryFile.prototype.forEachPackage = function(fn){
|
||||
RegistryFile.prototype.forEachRegistryEntry = function(fn){
|
||||
|
||||
return this.forEach(function(redirection, name){
|
||||
return this.forEach(function(canonicalPackageName, registryEntryName){
|
||||
|
||||
var pkg = {};
|
||||
var match = PACKAGE_EXPECTATION.exec(redirection);
|
||||
var match = CANONICAL_NAME_EXPECTATION.exec(canonicalPackageName);
|
||||
|
||||
if (!match) {
|
||||
pkg = {
|
||||
value: redirection,
|
||||
canonical: canonicalPackageName,
|
||||
endpoint: undefined,
|
||||
name: undefined,
|
||||
};
|
||||
|
||||
} else {
|
||||
pkg = {
|
||||
value: match[0],
|
||||
canonical: match[0],
|
||||
endpoint: match[1],
|
||||
name: match[2],
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
fn.call(this, pkg, name);
|
||||
|
||||
fn.call(this, pkg, registryEntryName);
|
||||
});
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user