This repository has been archived by the owner on Mar 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b239a7
commit 5c430f2
Showing
7 changed files
with
166 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var spec = require('./spec'); | ||
|
||
var normalize = spec.normalize; | ||
|
||
/** | ||
* Expose `local`. | ||
*/ | ||
|
||
module.exports = local; | ||
|
||
/** | ||
* Resolve all of the locally-installed dependencies for the component, both | ||
* in `paths` and in the install directory. | ||
* | ||
* @param {Function} fn | ||
*/ | ||
|
||
function local(fn){ | ||
var components = []; | ||
var dest = this.installTo(); | ||
|
||
fs.exists(dest, function(exists){ | ||
if (!exists) return fn(null, components); | ||
|
||
fs.readdir(dest, function(err, dirs){ | ||
if (err) return fn(err); | ||
|
||
for (var i = 0, dir; dir = dirs[i]; i++) { | ||
try { | ||
var json = require(path.join(dest, dir, 'component.json')); | ||
var conf = normalize.json(json); | ||
var repo = conf.repository; | ||
var component = { | ||
type: 'remote', | ||
name: repo, | ||
repository: repo, | ||
version: conf.version, | ||
conf: conf, | ||
json: json | ||
}; | ||
|
||
components.push(component); | ||
components[repo] = component; | ||
} catch (e) { | ||
return fn('Invalid JSON in locally-installed "' + dir + '".'); | ||
} | ||
} | ||
|
||
fn(null, components); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.