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-cp-r

v0.1.1

Published

Metalsmith plugin to copy folders recursively.

Downloads

41

Readme

Build Status License NPM Downloads Known Vulnerabilities

metalsmith-cp-r

A Metalsmith plugin to copy files recursively. Similar to metalsmith-assets but:

  • cp-r has minimal dependencies (only debug)
  • cp-r offers several additional options and controls

Usage

Install as usual, npm install metalsmith-cp-r.

Javascript: use(metalsmith-cp-r(options))

CLI: You'll lose a few options since you can't pass functions.

Options

from: the contents of this directory, or this file, will be copied. Defaults to "_directory/assets" (see below).

to:      into this directory. It will be created if necessary. Defaults to "_destination/assets".

If from or to starts with _XXX/, they will be relative to that metalsmith property. Common ones are:

Warning If you use this feature, you must use '/' (not a Windows '\\') as your folder delimiter.

e.g. to copy from the working directory into the folder you set in metalsmith.destination() use

{ from: "_directory/pathto/assets", to: "_destination/pathto/assets"}.

Otherwise, the path will be resolved normally using path.resolve(). (Sorry, if you really want to copy to or from a folder starting with _, the workaround is to start the path with a . or / or something...)

Less common options, all default to null

noclobber: if truthy, don't overwrite existing files. (Note: cp-r never overwrites existing folders)

dirMode     e.g. 0o777 copied dirs will have this "mode", default = use same mode as existing dir.

fileMode    e.g. 0o666 copied files will have this "mode", default = use same mode as existing file.

ignoreDir   a string or Regex, if present, ignore directories matching this pattern.

ignoreFile   a string or Regex, if present, ignore files matching this pattern.

Notes, Todos, and Caveats

cp-r doesn't do any fancy async stuff - didn't seem worth it for a simple build script. (It really feels "un-nody" because of all the synch stuff!)

cp-r has not been tested with links, locked directories, bad inputs, other weird stuff.

The "unit-test" is pretty lame. In package.json, please set scripts.test to the value for testWindows or testUnix as appropriate.

I wrote this because metalsmith-assets had a ton of obsolete dependencies and wasn't actively processing issues and pull requests. cp-r uses an absolute minimum of dependencies (only debug) and implements a few features from metalsmith-assets' feature requests.

metalsmith-assets-improved looks comparable.

metalsmith-copy-assets-540 isn't recursive.

It's possible that metalsmith-copy does this better.