Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Fix failing test and make crap compatible with strict mode #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crap.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var parallel = require('./parallel.js');
var url = require("url");
var path = require("path");
Expand All @@ -11,9 +13,13 @@ var types = ["apis","apps","middleware","controllers","providers","resources"];
var crap = module.exports = {
root: process.cwd(),
get config() {
if (this._config) return this._config;
var p = crap.root + '/crap.config.js';
return crap.open(p);
},
set config(cf) {
this._config = cf;
},
open: function(filename) {
var result = cache[filename];
if(!result) {
Expand Down
31 changes: 19 additions & 12 deletions test/load.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var crap = require("../");
var config = require("./crap.verbose.config.js");
var should = require('should');
Expand Down Expand Up @@ -47,6 +49,7 @@ describe('crap load', function () {
.catch(done);
});
}

describe('without Promises', function () {
if(typeof Promise!=='undefined') {
var promise = Promise;
Expand All @@ -56,26 +59,30 @@ describe('crap load', function () {
}

it('should load an entire chain of CRaP', function (done) {
Promise = undefined;
crap.load.apps(config, function(err, apps) {
should.not.exist(err);
should.exist(apps);
apps.should.eql(interfaces);
done();
});
});

it('should load an entire chain of CRaP using local configs', function (done) {
crap.load.apps('profile', {
root: __dirname,
apps:{profile: require('./apps/profile.js').deps()}
}, function(err, apps) {
should.not.exist(err);
should.exist(apps);
apps.should.eql(interfaces);
done();
});
});
});
});

it('should load an entire chain of CRaP using local configs', function (done) {
Promise = undefined;
crap.load.apps('profile', {
root: __dirname,
apps:{profile: require('./apps/profile.js').deps()}
}, function(err, apps) {
should.not.exist(err);
should.exist(apps);
apps.should.eql(interfaces);
done();
it('should load crap config', function () {
crap.config = config;
crap.config.should.eql(config)
});
});