pathmap
Rake's pathmap for JavaScript. Think of it like sprintf
for paths.
Usage
pathmap
accepts a path and a pathmap spec and returns a formatted string.
var pathmap = ;; // => 'rm file.txt'; // => 'mv file.coffee file.js'
The following patterns are supported:
%p
- The complete path.%f
- The base file name of the path, with its file extension, but without any directories.%n
- The file name of the path without its file extension.%d
- The directory list of the path.%x
- The file extension of the path. An empty string if there is no extension.%X
- Everything but the file extension.%s
- The file separator. This can be configured by settingpathmap.sep
.%%
- A percent sign.
The %d
pattern supports a count
argument to specify the number of directories to return from either side.
; // => 'a/b'; // => 'c/d'
%p
, %f
, %n
, %d
, %x
and %X
support a replacement argument that can be used to replace portions of the resulting string. The pattern looks like "{old,new}".
; // => 'file.mdown'