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

regex-copy

v1.0.3

Published

Copy and remove files with glob pattern(**,*,{},!{}) and regular expression

Downloads

3

Readme

regex-copy

Copy and remove files with one command. Also, a regular expression can filter files that will be copied or removed.

Features

  • Recursively copy the whole directory.
  • Copy several directories (to one directory) at once.
  • Remove files after files were copied, if you want.
  • Can be used in two-way (cli and es-module).

As a cli tool

$ regex-copy -r '^(.*)\.js$' -d './dist' './src'
$ rgcp './src' './dist'
$ rgcp './src1' './src2' './dist'
$ rgcp './src1' './src2' './src3' ... './srcn' './dist'
$ rgcp './src' './dist' -e '**/*.ts' -r '**/*.js' -p '**/*.ts'

Options

  • -e: Determines which files to exclude from copy in glob pattern.
  • --exclude: Determines which files to exclude from copy in glob pattern. It takes Array expressed by JSON string as a parameter.
  • -E: Determines which files to exclude from copy in regular expression.
  • --regex-exclude: Determines which files to exclude from copy in regular expression. It takes Array expressed by JSON string as a parameter.
  • -r: Determines which files to remove in glob pattern.
  • --remove: Determines which files to remove in glob pattern. It takes Array expressed by JSON string as a parameter.
  • -R: Determines which files to remove in regular expression.
  • --regex-remove: Determines which files to remove in regular expression. It takes Array expressed by JSON string as a parameter.
  • -p: Determines which files to preserve in glob pattern.
  • --preserve: Determines which files to preserve in glob pattern. It takes Array expressed by JSON string as a parameter.
  • -P: Determines which files to preserve in regular expression.
  • --regex-preserve: Determines which files to preserve in regular expression. It takes Array expressed by JSON string as a parameter.
  • -f, --flat: Determines uncovering folder level.
  • -t: Whether to test targets. If this flag set as true, no file system action will be performed
  • --reset: Whether to empty destination before copying. If this flag set as true, empty destination directory before copying files

As an es-module

import { regexCopy } from "regex-copy";
regexCopy( [ ...[ paths ], dest ], { enlist, exclude, remove, preserve, flat, removeEmpty, test } )// Returns a Promise with undefined.

Example

import { regexCopy } from "regex-copy";
regexCopy( [ "C:/Users/Isitea/AppData/Local/Temp", "C:/Users/Default/AppData/Local/Temp", "C:/Temp" ], { exclude: [ /.+/, "**/*" ], remove: [ "**/*.tmp" ], preserve: [ "**/*" ], test: true, reset: true } );

As an es-module for Deno

import { regexCopy } from "https://deno.land/x/[email protected]/mod.ts";

Arguments:

| Name | Type | Required | Default | Description | | ---- | ---- | -------- | ------- | ----------- | | path | string | Yes | N/A | Source files or folder. It can be expressed with a glob pattern | | dest | string | Yes | N/A | Destination folder path | | options.enlist | Array<RegExp,string> | No | [] | Regular expression / glob pattern that determines which files to copy | | options.exclude | Array<RegExp,string> | No | [] | Regular expression / glob pattern that determines which files to copy | | options.remove | Array<RegExp,string> | No | [] | Regular expression / glob pattern that determines which files to copy | | options.preserve | Array<RegExp,string> | No | [] | Regular expression / glob pattern that determines which files to copy | | options.flat | number | No | 1 | Determines uncovering folder level. | | options.removeEmpty | boolean | No | true | Whether to remove empty source folder after remove | | options.reset | boolean | No | false | Whether to empty destination before copying. If this flag set as true, empty destination directory before copying files | | options.test | boolean | No | false | Whether to test targets. If this flag set as true, no file system action will be performed |