Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $ npm install consign
* Test driven
* Fast, Light-weight with no external dependencies
* Highly configurable
* Passes in relative path to included module as last argument

## Options

Expand Down
1 change: 1 addition & 0 deletions lib/consign.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Consign.prototype.into = function(object) {
for (var a in arguments) {
args.push(arguments[a]);
}
args.push(this._getRelativeTo(script));

if ('function' === typeof mod) {
mod = mod.apply(mod, args);
Expand Down
42 changes: 36 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions test/into.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,14 @@ module.exports = function(consign, assert) {
assert.equal(app.controllers.one.run, true);
});

it('Should pass in the relative path to the loaded item as the last argument', function() {
var app = {};
consign(options)
.include('controllers')
.into(app)
;

assert.equal(app.controllers.two.relativePath, './controllers/two.js');
});
};

3 changes: 2 additions & 1 deletion test/test-app/controllers/two.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @license MIT
*/

module.exports = function(app) {
module.exports = function(app, relativePath) {
if (relativePath) this.relativePath = relativePath;
return this;
};