npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-move-up

v3.0.0

Published

a MetalSmith plugin for moving the full contents of a directory up one or more levels

Downloads

74

Readme

metalsmith-move-up

travis git npm standard

Metalsmith MoveUp is a MetalSmith plugin for moving the full contents of a directory up one or more levels. By default this plugin will move everything in your destination directory up one. Metalsmith MoveUp supports multiple transforms, which are processed in the order they are provided, allowing for more complex transforms to be done with a single call.

For globbing support we use minimatch. To make matching easier we set dot matching to true meaning a global match can be done using a single globstar **. MiniMatch options can be provided as a global or on a per transform basis.

Installation

To install Metalsmith MoveUp, simply use npm:

npm install metalsmith-move-up --save

Usage

The example below can be found and ran from the eg folder; it demonstrates how to use Metalsmith MoveUp in a couple of different ways in a node.js app.

Javascript

'use strict'

var metalsmith = require('metalsmith'),
    moveUp = require('metalsmith-move-up')

// move everything in the build folder up one. The
// build folder always represents the root for operations.
metalsmith.use(moveUp())

// defaults are added as needed so input is easier. Input
// is simplified where possible. both lines will have a
// default .by of 1 and will use dot:true for mini-match.
metalsmith.use(moveUp('pages/*'))
metalsmith.use(moveUp({pattern: 'pages/*'}))

// multiple simple transforms are also supported.
metalsmith.use(moveUp([
  'lib/**',
  'test/*'
]))

// multiple, order specific, transforms can be done with one
// call. Each job only begins after the previous one finishes.
metalsmith.use(moveUp([
  '!*.css',
  'index.css'
]))

// the .by field moves everything N or as many times as
// possible. This means if a given match only has one path
// part, it will only be moved up one directory.
metalsmith.use(moveUp({
  pattern: 'pages/*',
  by: 2
}))

// globbing is supported via minimatch. default options for
// minimatch can be supplied at a global level using the .opts
// field. Transforms are added to the .transforms array, any
// transform that does not have a .opts field will get the
// global .opts value. This is a replace, not a merge.
metalsmith.use(moveUp({
  opts: {
    dot: false
  },
  transforms: [
    {pattern: 'pages/*', by: 2},
    {pattern: 'css/*', by: 2, opts: {dot: true}}
  ]
}))

Metalsmith JSON

{
  "source": "./src",
  "destination": "./dest",
  "plugins": {
    "metalsmith-move-up": {
      "opts": {"dot": "true"},
      "transforms": [
        {"pattern": "**", "by": "2"},
        {"pattern": "posts/*", "by": "2", "opts": {"dot": "false"}}
      ]
    }
  }
}

Transform

The transform object has three fields, if no transforms are passed a default pattern will be ran that pulls all applicable files and folders in the build directory up by one.

pattern

The glob pattern to use when locating files and directories for moving. See both minimatch for example patterns.

by

The maximum number of path parts to remove. Matches with less path segments than the count will have all of their segments removed, as such, they will end up in the root (destination) folder.

opts

The options to use with minimatch, order is field > global > default each overriding the last. Note that these options do not merge, they overwrite.

Contributing

Metalsmith MoveUp is an open project and encourages participation. If you feel you can help in any way, be it with examples, extra testing, or new features please be our guest.

See our Contribution Guide for information on obtaining the source and an overview of the tooling used.

License

Copyright Dean McDonnell 2015, Licensed under MIT