read-components
Advanced tools
Comparing version 0.6.1 to 0.7.0
54
index.js
var sysPath = require('path'); | ||
var fs = require('fs'); | ||
var each = require('async-each'); | ||
var events = require('events'); | ||
var emitter = new events.EventEmitter(); | ||
@@ -18,4 +16,2 @@ var jsonPaths = { | ||
var Builder = require('component-builder'); | ||
var jsonProps = ['main', 'scripts', 'styles']; | ||
@@ -28,4 +24,6 @@ | ||
fs.exists(bowerrcPath, function(hasBowerrc) { | ||
if (hasBowerrc) { | ||
fs.access(bowerrcPath, function(error) { | ||
if (error) { | ||
callback(null, defaultBowerDir); | ||
} else { | ||
fs.readFile(bowerrcPath, 'utf8', function(error, bowerrcContent) { | ||
@@ -38,8 +36,4 @@ if (error) return callback(error); | ||
}); | ||
} else { | ||
callback(null, defaultBowerDir); | ||
} | ||
}); | ||
} else if (type == 'component') { | ||
return callback(null, 'components'); | ||
} else { | ||
@@ -71,4 +65,4 @@ return callback(null); | ||
var readJson = function(file, type, callback) { | ||
fs.exists(file, function(exists) { | ||
if (!exists) { | ||
fs.access(file, function(error) { | ||
if (error) { | ||
var err = new Error('Component must have "' + file + '"'); | ||
@@ -122,6 +116,6 @@ err.code = 'NO_'+ type.toUpperCase() +'_JSON'; | ||
var dotpath = getJsonPath(path, 'dotbower'); | ||
var _read = function(actualPath) { | ||
readJson(actualPath, type, function(error, json) { | ||
if (error) return callback(error); | ||
@@ -151,4 +145,4 @@ if (overrides) { | ||
}; | ||
fs.exists(dotpath, function(isStableBower) { | ||
_read(isStableBower ? dotpath : fullPath) | ||
fs.access(dotpath, function(isUnstableBower) { | ||
_read(isUnstableBower ? fullPath : dotpath); | ||
}); | ||
@@ -258,3 +252,2 @@ }; | ||
var readComponents = function(directory, callback, type) { | ||
@@ -282,14 +275,3 @@ if (typeof directory === 'function') { | ||
var sorted = sortPackages(data, type); | ||
aliases = []; | ||
if (type === 'component') | ||
{ | ||
builder = new Builder(directory); | ||
var aliases = []; | ||
emitter.on('addAlias', function(alias) {aliases.push(alias);}) | ||
builder.buildAliases(function(err, res) { | ||
callback(null, sorted, aliases); | ||
}); | ||
} | ||
else | ||
callback(null, sorted); | ||
callback(null, sorted); | ||
}); | ||
@@ -299,19 +281,7 @@ }); | ||
Builder.prototype.alias = function(a,b) { | ||
var name = this.root | ||
? this.config.name | ||
: this.basename; | ||
var res = {}; | ||
res[name + '/' + b] = a; | ||
emitter.emit('addAlias', res) | ||
return 'require.alias("' + name + '/' + b + '", "' + a + '");'; | ||
}; | ||
var read = function(root, type, callback) { | ||
if (type === 'bower') { | ||
readComponents(root, callback, type); | ||
} else if (type === 'component') { | ||
readComponents(root, callback, type); | ||
} else { | ||
throw new Error('read-components: unknown type'); | ||
throw new Error('read-components: unknown type ' + type); | ||
} | ||
@@ -318,0 +288,0 @@ }; |
{ | ||
"name": "read-components", | ||
"version": "0.6.1", | ||
"description": "Read bower and component(1) components", | ||
"version": "0.7.0", | ||
"description": "Read bower components", | ||
"main": "index.js", | ||
@@ -13,4 +13,3 @@ "scripts": { | ||
"dependencies": { | ||
"async-each": "~0.1.3", | ||
"component-builder": "~0.10.0" | ||
"async-each": "~1.0.0" | ||
}, | ||
@@ -17,0 +16,0 @@ "devDependencies": { |
# read-components [![Build Status](https://travis-ci.org/paulmillr/read-components.svg?branch=add-travis)](https://travis-ci.org/paulmillr/read-components) | ||
Read Twitter Bower and component(1) components. | ||
Read Twitter Bower components. | ||
@@ -71,4 +71,2 @@ Install with `npm install read-components`. | ||
// Second argument is type, | ||
// in future it will support component(1). | ||
read('your-project-dir-with-bower.json', 'bower', function(error, components) { | ||
@@ -75,0 +73,0 @@ console.log('All components:', components); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13736
1
6
237
131
+ Addedasync-each@1.0.6(transitive)
- Removedcomponent-builder@~0.10.0
- Removedasync-each@0.1.6(transitive)
- Removedbatch@0.2.1(transitive)
- Removedcomponent-builder@0.10.1(transitive)
- Removedcomponent-require@0.3.1(transitive)
- Removedcp@0.1.1(transitive)
- Removeddebug@4.4.0(transitive)
- Removedmkdirp@0.3.4(transitive)
- Removedms@2.1.3(transitive)
- Removedstring-to-js@0.0.1(transitive)
Updatedasync-each@~1.0.0