Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

metalsmith-renamer

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

metalsmith-renamer

Plugin to take a pattern and rename each matched file

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
348
increased by155.88%
Maintainers
1
Weekly downloads
 
Created
Source

metalsmith-renamer

This is a plugin for Metalsmith that renames files matching a given pattern. Presently it only accepts files, not folders, but folder renaming is planned for the near future.

Usage

If using the CLI for Metalsmith, metalsmith-renamer can be used like any other plugin by including it in metalsmith.json. For example:

{
  "plugins": {
    "metalsmith-renamer": {
      "filesToRename": {
        "pattern": "folder/**/*.md",
        "rename": "newName.md"
      },
      "moreFiles": {
        "pattern": "folder/about.html",
        "rename": "index.html"
      }
    }
  }
}

For Metalscript's JavaScript API, metalsmith-renamer can be used like any other plugin, by attaching it to the function invocation chain on the Metalscript object. For example:

var renamer = require('metalsmith-renamer');
require('metalsmith')(__dirname)
  .use(renamer({
    filesToRename: {
      pattern: 'folder/**/*.md',
      rename: 'newName.md'
    },
    moreFiles: {
      pattern: 'folder/about.html',
      rename: 'index.html'
    }, //and as many more patterns as you want
  }
})
.build();

Options

metalsmith-renamer has two options, both of which must be defined:

  • pattern option which uses minimatch to filter files.
  • rename which takes a string argument for what you'd like the files to be named.

Use cases

  • I use it to simulate metalsmith-permalinks partially by renaming certain files index.html, allowing me to link straight to directories and not have to use the filename. metalsmith-permalink insists on enclosing files within a structured folder system, whereas I have folder already organized manually.

Roadmap

  • v0.1 Core renaming functionality
  • v0.2 Allow specifying multiple inputs, avoiding the need to call the plugin multiple times.
  • v0.3 Allow renaming of directories.
  • v0.4 Clean up declaration method to take named objects, or a single unnamed one.

Keywords

FAQs

Package last updated on 29 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc