Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-components

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-components - npm Package Compare versions

Comparing version 0.6.1 to 0.7.0

CHANGELOG.md

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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc