Skip to content

Commit

Permalink
Move object dependencies to manifest. For #1867
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Jul 9, 2019
1 parent b8dab8a commit 337952f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
6 changes: 2 additions & 4 deletions lib/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ exports.describe = function (schema) {

// Inners

const inners = ['renames', 'patterns', 'notes', 'tags', 'meta', 'examples', 'alterations', 'externals', 'items', 'ordered', 'matches', 'map', 'truthy', 'falsy'];
const inners = ['dependencies', 'renames', 'patterns', 'notes', 'tags', 'meta', 'examples', 'alterations', 'externals', 'items', 'ordered', 'matches', 'map', 'truthy', 'falsy'];
for (const inner of inners) {
// for (const inner in schema._inners) {
const items = schema._inners[inner];
Expand Down Expand Up @@ -195,9 +195,7 @@ exports.describe = function (schema) {

internals.inner = function (item) {

if (Common.isSchema(item) ||
Common.isResolvable(item)) {

if (typeof item.describe === 'function') {
return item.describe();
}

Expand Down
31 changes: 22 additions & 9 deletions lib/types/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,6 @@ internals.Object = class extends Any {
}
}

if (this._inners.dependencies) {
description.dependencies = [];
for (const dep of this._inners.dependencies) {
const { type, key, paths } = dep;
description.dependencies.push({ type, key: key.key, peers: paths });
}
}

return description;
}

Expand Down Expand Up @@ -605,7 +597,7 @@ internals.Object = class extends Any {

const obj = this.clone();
obj._inners.dependencies = obj._inners.dependencies || [];
obj._inners.dependencies.push({ type, key, peers: paths, paths: peers });
obj._inners.dependencies.push(new internals.Dependency(type, key, paths, peers));
return obj;
}

Expand Down Expand Up @@ -1017,4 +1009,25 @@ internals.clone = function (value, prefs) {
};


internals.Dependency = class {

constructor(type, key, peers, paths) {

this.type = type;
this.key = key;
this.peers = peers;
this.paths = paths;
}

describe() {

return {
type: this.type,
key: this.key.key,
peers: this.paths
};
}
};


module.exports = new internals.Object();

0 comments on commit 337952f

Please sign in to comment.