Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.
/ hoast-rename Public archive

Hoast module used to rename the path of files using a specified function.

License

Notifications You must be signed in to change notification settings

hoast/hoast-rename

Repository files navigation

Deprecated: The hoast-convert does everything this module can do, and more!

npm package @latest npm package @next

Travis-ci status CodeCov coverage

License agreement Open issues on GitHub

hoast-rename

Rename the path of files using a specified function.

As the name suggest this is a hoast module.

Usage

Install hoast-rename using npm.

$ npm install hoast-rename

Parameters

  • 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 type String. 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
  • 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 or Array of strings
      • Required: no
  • patternOptions: Options for the glob pattern matching. See planckmatch options for more details on the pattern options.
    • Type: Object
    • Default: {}
  • patternOptions.all: This options is added to patternOptions, and determines whether all patterns need to match instead of only one.
    • Type: Boolean
    • Default: false

Examples

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.

About

Hoast module used to rename the path of files using a specified function.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published