middleware-rename-file is a Node.js middleware designed for dynamically renaming Vinyl file objects by leveraging properties defined within their YAML front-matter. Currently at version 1.0.0, the package appears to be in a maintenance state, with no active feature development. It targets older Node.js environments (engines >=0.10.0) and is primarily integrated with established templating and static site generation frameworks such as Assemble, Verb, Generate, and Templates. The core functionality allows developers to specify new `basename` and `dirname` attributes directly in a file's front-matter, which the middleware then applies to the file's destination path early in the build pipeline, typically via an `onLoad` event. This declarative approach to file renaming is a key differentiator, providing a structured way to manage file output within its target ecosystems.
npm install middleware-rename-fileVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `middleware-rename-file` function by mocking a Vinyl file object and applying renaming based on front-matter properties, including an example with a filter function.
Use `const renameMiddleware = require('middleware-rename-file');` for importing the module.Ensure your file's YAML front-matter includes a top-level `rename` key with `basename` and/or `dirname` properties, for example: ```yaml --- rename: basename: new-name.html dirname: new/path --- ```
If encountering issues in modern Node.js environments, consider porting the logic or using a more actively maintained alternative. However, for its specific use-case within the Assemble/Templates ecosystem, it generally remains functional.
When using outside of the intended ecosystem, ensure your build process correctly parses front-matter into the `file.data` property and that you are passing valid Vinyl-like file objects to the middleware.
Use CommonJS `require`: `const renameMiddleware = require('middleware-rename-file');`.Verify the front-matter structure for the `rename` key and its sub-properties. If a filter function is used, ensure it returns `true` for files that should be renamed.
No dependency data recorded yet.