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

compound

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compound - npm Package Compare versions

Comparing version 1.1.7-3 to 1.1.7-4

43

lib/compound.js

@@ -28,3 +28,8 @@ var fs = require('fs'),

this.__localeData = {};
this.structure = null;
this.structure = {
controllers: {},
models: {},
helpers: {},
views: {}
};
this.locales = [];

@@ -63,3 +68,3 @@ this.utils = compoundUtils;

process.nextTick(function() {
compound.init();
compound.init(root);
});

@@ -87,5 +92,7 @@ }

*/
Compound.prototype.init = function initCompound() {
Compound.prototype.init = function initCompound(root) {
var compound = this;
root = root || compound.root;
// run environment.{js|coffee}

@@ -95,3 +102,3 @@ // and environments/{test|development|production}.{js|coffee}

if (isServerSide && compound.app) {
configureApp(compound);
compound.configure(root);
}

@@ -105,3 +112,3 @@ compound.emit('after configure');

compound.emit('extensions', compound);
compound.extensions();
compound.extensions(root);
compound.emit('after extensions', compound);

@@ -123,7 +130,9 @@

compound.structure = compound.structure();
if ('function' === typeof compound.loadStructure) {
compound.loadStructure(root);
}
compound.emit('structure', compound.structure, compound);
// init models in app/models/*
require('./models')(compound);
require('./models')(compound, root);
compound.emit('models', compound.models, compound);

@@ -133,7 +142,7 @@

if (isServerSide) {
runInitializers(compound);
compound.runInitializers(root);
}
compound.emit('initializers', compound);
compound.i18n(compound);
compound.i18n(compound, root);

@@ -169,8 +178,11 @@ compound.emit('ready', compound);

*/
function configureApp(compound) {
Compound.prototype.configure = function configureApp(root) {
var compound = this;
var app = compound.app;
var root = compound.root;
root = root || compound.root;
var mainEnv = root + '/config/environment';
app.set('views', root + '/app/views');
if (!app.get('views')) {
app.set('views', root + '/app/views');
}
requireIfExists(compound, mainEnv + '.js') ||

@@ -227,5 +239,5 @@ requireIfExists(compound, mainEnv + '.coffee');

*/
function runInitializers(compound) {
var queue,
initializersPath = path.join(compound.root, 'config', 'initializers');
Compound.prototype.runInitializers = function runInitializers(root) {
var queue, compound = this, initializersPath = path.join(
root || compound.root, 'config', 'initializers');

@@ -251,3 +263,2 @@ if (existsSync(initializersPath)) {

}
}

@@ -40,3 +40,3 @@ var Compound = require('../compound');

this.middleware = require('./middleware');
this.structure = require('./structure')(this);
this.loadStructure = require('./structure')(this);
this.__defineGetter__('version', function() {

@@ -158,4 +158,3 @@ return require('../../package').version;

app.express2 = !!express.version.match(/^2/);
app.express3 = !!express.version.match(/^3/);
app.express3 = true;

@@ -162,0 +161,0 @@ return app;

@@ -6,18 +6,34 @@ var fs = require('fs');

module.exports = function(rw) {
var debug = function(){};
return function() {
return {
views: read('app/views', 'view'),
helpers: read('app/helpers', true),
controllers: read('app/controllers', 'controller'),
models: read('app/models', true)
};
module.exports = function(compound) {
if (process.env.NODE_DEBUG && /structure/.test(process.env.NODE_DEBUG)) {
debug = compound.log;
}
return function(root) {
root = root || compound.root;
debug('Loading structure from ' + root);
read(root, 'views', 'app/views', 'view');
read(root, 'helpers', 'app/helpers', true);
read(root, 'controllers', 'app/controllers', 'controller');
read(root, 'models', 'app/models', true);
};
function read(dir, doRequire, cts, prefix) {
var contents = cts || {};
var abspath = rw.root + '/' + dir;
function read(root, key, dir, doRequire, cts, prefix) {
var contents;
if (cts) {
contents = cts;
} else {
if (compound.structure[key]) {
compound.structure[key] = {};
}
contents = compound.structure[key];
}
var abspath = root + '/' + dir;
prefix = prefix || '';
debug('read ' + key + ' from ' + abspath);
if (fs.existsSync(abspath)) {

@@ -27,5 +43,5 @@ fs.readdirSync(abspath).forEach(readAndWatch);

return contents;
function readAndWatch(filename) {
debug('read', filename);
function readAndWatch(filename) {
if (filename.match(/^\./)) {

@@ -51,7 +67,16 @@ // skip files starting with point

}
contents[name] =
doRequire ?
var item = doRequire ?
requireFile(file, doRequire) :
fs.readFileSync(file).toString();
if (name in contents) {
if ('function' === typeof item) {
for (var i in item.prototype) {
contents[name].prototype[i] = item[i];
}
}
} else {
contents[name] = item;
}
if (ext === 'coffee' && !doRequire) {

@@ -66,3 +91,3 @@ try {

if (false && rw.app.enabled('watch')) {
if (false && compound.app.enabled('watch')) {

@@ -69,0 +94,0 @@ fs.watch(file, function() {

{
"name": "compound",
"version": "1.1.7-3",
"version": "1.1.7-4",
"author": "Anatoliy Chakkaev",

@@ -5,0 +5,0 @@ "contributors": [

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