map-dest 
Map the destination path for a file based on the given source path and options.
Install
Install with npm
$ npm i map-dest --save
Usage
var mapDest = require('map-dest');
Table of contents
docs
src
Returns an array when src is an array
mapDest(['a.txt', 'b.txt'], 'dist');
dest
Creates a dest when no dest argument is passed.
mapDest('a/b/c.txt');
When no dest is defined and src is an array, returns an array with generated dest paths.
mapDest(['a.txt', 'b.txt']);
options
options.flatten
Flattens dest when no dest argument is passed:
mapDest('a/b/c.txt', {flatten: true});
options.ext
Replaces the destination extension with given ext:
mapDest('a/b/c.txt', {ext: '.foo'});
options.cwd
When cwd is defined it will be prepended to src:
mapDest('a/b/c.txt', {cwd: 'one/two'});
Prepends cwd to src and flattens dest:
mapDest('a/b/c.txt', {cwd: 'one/two', flatten: true});
Expands tildes in cwd to make the path relative to the user's home directory:
mapDest('a/b/c.txt', {cwd: '~/one/two'});
Expands @ in cwd to make the path relative to global npm modules:
mapDest('templates/base.hbs', {cwd: '@/boilerplate-h5bp'});
options.destBase
If destBase is defined it's prepended to generated dest.
mapDest('a/b/c.txt', {destBase: 'one/two'});
If destBase is defined, it will be prepended to dest
mapDest('a/b/c.txt', 'foo', {destBase: 'one/two'});
options.rename
A custom rename function can be used to modify the generated dest path.
mapDest('a/b/c.md', {
rename: function (dest, src, opts) {
return 'dist/' + path.basename(src) + '.html';
}
});
Related projects
Test coverage
-----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
-----------|----------|----------|----------|----------|----------------|
map-dest/ | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
-----------|----------|----------|----------|----------|----------------|
All files | 100 | 100 | 100 | 100 | |
-----------|----------|----------|----------|----------|----------------|
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert
Released under the MIT license.
This file was generated by verb-cli on October 30, 2015.