Skip to content

Commit

Permalink
Feat: To respect modules with ../../ in path niquola#2.
Browse files Browse the repository at this point in the history
`Require` respects modules wich contain `../../` in path.
  • Loading branch information
danil committed Feb 3, 2016
1 parent ece817c commit 7084ccb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
2016-02-03 Danil Kutkevich <[email protected]>

* src/loader.coffee (scan): Feat: `Require` respects modules wich
contain `../../` in path (#2).

2016-01-26 Danil Kutkevich <[email protected]>

* src/loader.coffee (generate_fn): respects functions with only
* src/loader.coffee (generate_fn): Respects functions with only
one argument (#1).
10 changes: 7 additions & 3 deletions src/loader.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ scan = (pth) ->
this.require = function(dep){
var abs_path = dep.replace(/\\.(coffee|litcoffee)$/, '');
var current = _current_stack[_current_stack.length - 1];
if(dep.match(/^\\.\\.\\//)){
if(dep.match(/^\\.\\.\\/\\.\\.\\//)){
var dir = current.dir.split('/');
dir.pop();
dir.pop();
abs_path = dir.join('/') + '/' + dep.replace('../../','');
} else if(dep.match(/^\\.\\.\\//)) {
var dir = current.dir.split('/');
dir.pop();
abs_path = dir.join('/') + '/' + dep.replace('../','');
}
else if(dep.match(/^\\.\\//)){
} else if(dep.match(/^\\.\\//)) {
abs_path = current.dir + '/' + dep.replace('./','');
}
// todo resolve paths
Expand Down

0 comments on commit 7084ccb

Please sign in to comment.