Use util.inherits in tool

This lets use look at self.constructor and see the right class rather
than BaseCatalog
This commit is contained in:
David Glasser
2014-06-24 17:18:25 -07:00
parent 9a9c8dc3db
commit d0d5805cb6
2 changed files with 9 additions and 16 deletions

View File

@@ -177,14 +177,6 @@ exports.ignoreFiles = [
/^\.git\/$/ /* often has too many files to watch */
];
// http://davidshariff.com/blog/javascript-inheritance-patterns/
var inherits = function (child, parent) {
var tmp = function () {};
tmp.prototype = parent.prototype;
child.prototype = new tmp;
child.prototype.constructor = child;
};
var rejectBadPath = function (p) {
if (p.match(/\.\./))
throw new Error("bad path: " + p);
@@ -769,7 +761,7 @@ var ClientTarget = function (options) {
throw new Error("ClientTarget targeting something that isn't a browser?");
};
inherits(ClientTarget, Target);
util.inherits(ClientTarget, Target);
_.extend(ClientTarget.prototype, {
// Lints CSS files and merges them into one file, fixing up source maps and
@@ -1306,7 +1298,7 @@ var JsImageTarget = function (options) {
throw new Error("JsImageTarget targeting something unusual?");
};
inherits(JsImageTarget, Target);
util.inherits(JsImageTarget, Target);
_.extend(JsImageTarget.prototype, {
toJsImage: function () {
@@ -1349,7 +1341,7 @@ var ServerTarget = function (options) {
throw new Error("ServerTarget targeting something that isn't a server?");
};
inherits(ServerTarget, JsImageTarget);
util.inherits(ServerTarget, JsImageTarget);
_.extend(ServerTarget.prototype, {
// Output the finished target to disk

View File

@@ -2,6 +2,7 @@ var fs = require('fs');
var path = require('path');
var semver = require('semver');
var _ = require('underscore');
var util = require('util');
var packageClient = require('./package-client.js');
var archinfo = require('./archinfo.js');
var packageCache = require('./package-cache.js');
@@ -13,7 +14,7 @@ var tropohouse = require('./tropohouse.js');
var watch = require('./watch.js');
var files = require('./files.js');
var utils = require('./utils.js');
var baseCatalog = require('./catalog-base.js').BaseCatalog;
var BaseCatalog = require('./catalog-base.js').BaseCatalog;
var files = require('./files.js');
var fiberHelpers = require('./fiber-helpers.js');
@@ -36,10 +37,10 @@ var ServerCatalog = function () {
self.offline = null;
// We inherit from the protolog class, since we are a catalog.
baseCatalog.call(self);
BaseCatalog.call(self);
};
ServerCatalog.prototype = Object.create(baseCatalog.prototype);
util.inherits(ServerCatalog, BaseCatalog);
_.extend(ServerCatalog.prototype, {
initialize : function (options) {
@@ -169,10 +170,10 @@ var CompleteCatalog = function () {
self.refreshing = false;
// We inherit from the protolog class, since we are a catalog.
baseCatalog.call(self);
BaseCatalog.call(self);
};
CompleteCatalog.prototype = Object.create(baseCatalog.prototype);
util.inherits(CompleteCatalog, BaseCatalog);
_.extend(CompleteCatalog.prototype, {
// Initialize the Catalog. This must be called before any other