Resolves a map of paths where some paths are relative to others in the same object. Useful for describing directory structures and for project configuration.
Install via npm:
npm install --save-dev relative-path-mapvar relativePathMap = require('relative-path-map');
relativePathMap({
root: 'root/path',
sub: '[root]/sub' // => 'root/path/sub'
});relativePathMap({
root: 'root/path',
obj: {
sub: '[root]/sub', // => 'root/path/sub'
file: '[sub]/file.js' // => 'root/path/sub/file.js'
}
});relativePathMap({
root: 'root/path',
arr: [
'[root]/sub', // => 'root/path/sub'
'[0]/file.js' // => 'root/path/sub/file.js'
]
});relativePathMap({
obj: {
sub: 'some/path',
},
dot: '[obj.sub]/dot-notation.js' // => // 'some/path/dot-notation.js'
});An object containing strings representing paths. Paths beginning with a
placeholder [<prop>] are relative to some other path in the same object, where
<prop> is a property name, e.g. [root], or a sub-property name, e.g
[root.src].
Type: object
Returns an object whose relative paths have been resolved.
Copyright © 2016 Akim McMath. Licensed under the MIT License.