component-as-module
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -192,9 +192,10 @@ var fs = require('fs') | ||
Loader.prototype.loadComponent = function(name, partial) { | ||
Loader.prototype.loadComponent = function(name, shortName) { | ||
if (this.components[name]) return this.components[name] | ||
var path = this.lookup(name) | ||
if (!path && partial) { | ||
if (!path && shortName && shortName != name) { | ||
// failed to lookup by fullname (like repo-foo) | ||
// let's try by partial name (foo) | ||
path = this.lookup(partial) | ||
path = this.lookup(shortName) | ||
} | ||
@@ -204,3 +205,3 @@ | ||
? new Loader(path, this).implicitPaths() | ||
: this.parent && this.parent.loadComponent(name) | ||
: this.parent && this.parent.loadComponent(name, shortName) | ||
@@ -207,0 +208,0 @@ if (!comp) throw new Error('Failed to lookup component ' + name) |
{ | ||
"name": "component-as-module", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Eldar Gabdullin <eldargab@gmail.com>", | ||
@@ -5,0 +5,0 @@ "description": "Require components from node programs as well as share them with npm community.", |
@@ -48,3 +48,4 @@ # component-as-module | ||
3) List dependencies. Because npm understands github urls you | ||
can safely specify them in a component style: | ||
can safely specify them in a component style. Dependencies | ||
from npm repository (assuming they are components) are also ok. | ||
@@ -57,3 +58,3 @@ ```json | ||
"baz": "org/baz", | ||
"qux": "*" // dependency from npm (assuming it is a component) is also ok. | ||
"qux": "*" | ||
} | ||
@@ -79,5 +80,5 @@ } | ||
"baz": "org/baz", | ||
"qux": "*", // dependency from npm (assuming it is a component) is also ok. | ||
"component-as-module": "*" // add additional component-as-module dependency | ||
}, | ||
"qux": "*", | ||
"component-as-module": "*" | ||
}, | ||
"main": "node-main" | ||
@@ -88,3 +89,3 @@ } | ||
After that you can safely publish it to npm. It will work like any other npm module. (Just don't forget to include | ||
`component.json` to package.) | ||
`component.json` in a package.) | ||
@@ -91,0 +92,0 @@ ## Why |
10351
7
111