-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4214 from trabus/fix-nested-adapters
[BUGFIX] correct relative import path for nested adapters
- Loading branch information
Showing
8 changed files
with
96 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
/** | ||
Returns a relative parent path string using the path provided | ||
@method getRelativeParentPath | ||
@param {String} path The path to relatively get to. | ||
@return {String} the relative path string. | ||
*/ | ||
getRelativeParentPath: function getRelativeParentPath(path, offset) { | ||
var offsetValue = offset || 0; | ||
return new Array(path.split('/').length + 1 - offsetValue).join('../'); | ||
}, | ||
|
||
/** | ||
Returns a relative path string using the path provided | ||
@method getRelativePath | ||
@param {String} path The path to relatively get to. | ||
@return {String} the relative path string. | ||
*/ | ||
getRelativePath: function getRelativePath(path, offset) { | ||
var offsetValue = offset || 0; | ||
var relativePath = new Array(path.split('/').length - offsetValue).join('../'); | ||
return relativePath || './'; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect; | ||
var pathUtils = require('../../../lib/utilities/path'); | ||
|
||
describe('path.getRelativeParentPath', function() { | ||
it('should return parent paths', function() { | ||
expect(pathUtils.getRelativeParentPath('')).to.equal('../'); | ||
expect(pathUtils.getRelativeParentPath('foo')).to.equal('../'); | ||
expect(pathUtils.getRelativeParentPath('foo/bar')).to.equal('../../'); | ||
expect(pathUtils.getRelativeParentPath('foo/bar/baz')).to.equal('../../../'); | ||
}); | ||
|
||
it('should allow an offset value', function() { | ||
expect(pathUtils.getRelativeParentPath('',1)).to.equal(''); | ||
expect(pathUtils.getRelativeParentPath('foo',1)).to.equal(''); | ||
expect(pathUtils.getRelativeParentPath('foo/bar', 1)).to.equal('../'); | ||
expect(pathUtils.getRelativeParentPath('foo/bar/baz', 2)).to.equal('../'); | ||
}); | ||
}); | ||
|
||
describe('path.getRelativePath', function() { | ||
it('should return the relative path', function() { | ||
expect(pathUtils.getRelativePath('')).to.equal('./'); | ||
expect(pathUtils.getRelativePath('foo')).to.equal('./'); | ||
expect(pathUtils.getRelativePath('foo/bar')).to.equal('../'); | ||
expect(pathUtils.getRelativePath('foo/bar/baz')).to.equal('../../'); | ||
}); | ||
|
||
it('should allow an offset value', function() { | ||
expect(pathUtils.getRelativePath('', 1)).to.equal('./'); | ||
expect(pathUtils.getRelativePath('foo', 1)).to.equal('./'); | ||
expect(pathUtils.getRelativePath('foo/bar', 1)).to.equal('./'); | ||
expect(pathUtils.getRelativePath('foo/bar/baz', 1)).to.equal('../'); | ||
expect(pathUtils.getRelativePath('foo/bar/baz', 2)).to.equal('./'); | ||
}); | ||
}); |