Deprecated: The hoast-convert does everything this module can do, and more!
Rename the path of files using a specified function.
As the name suggest this is a hoast module.
Install hoast-rename using npm.
$ npm install hoast-rename
engine
: A function that processes the file path and returns the new one. The function should take one parameter the file path, which is of typeString
. Do note the function can be asynchronous or return a promise. The function needs the return the new content in the form of a string.- Type:
Function
- Required:
yes
- Required:
- Type:
patterns
: Glob patterns to match file paths with. If the engine function is set it will only give the function any files matching the pattern.- Type:
String
orArray of strings
- Required:
no
- Required:
- Type:
patternOptions
: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.- Type:
Object
- Default:
{}
- Type:
patternOptions.all
: This options is added topatternOptions
, and determines whether all patterns need to match instead of only one.- Type:
Boolean
- Default:
false
- Type:
Cli
Not compatible with the CLI tool as it requires a reference to a self specified function.
Script
const Hoast = require(`hoast`);
const read = Hoast.read,
rename = require(`hoast-rename`);
Hoast(__dirname)
.use(read())
.use(rename({
engine: function(filePath) {
return filePath.substr(0, filePath.lastIndexOf(`.`)).concat(`md`);
},
patterns: `*.markdown`
}))
.process();
In the example only the markdown files with the
.markdown
extension are renamed to.md
.