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

ldcp

v0.1.6

Published

low dependency cp

Downloads

5

Readme

ldcp (low dependency cp)

npm GitHub Build Status

Why? Because a popular cp clone in node is 46k lines of JavaScript and 197 dependencies!

This one is 148 lines and has no dependencies.

It tries to do the same as cp though it only supports the -R option.

What's the point?

I needed to copy a file as part of my build. I can't use cp because that's not cross platform (doesn't work on Windows). I'm usually on MacOS but I also run Windows and have friends that do dev on Windows. I could have used grunt and grunt-contrib-copy or some other giant build framework but I just wanted to add an inline script in package.json like

"scripts": {
  "build": "rollup && ldcp somefile dist/somefile"
}

I went looking for an existing solution. I'm sure it exists but the first one I found was very popular and also 450k lines of dependencies. Ridiculous! I actually solved the issue, copying a single file, with a 4 line .js file but just for fun I thought I'd see how much work it would be to write a small cp clone. This is result.

Installation

npm install ldcp

Usage

ldcp [-R] src_file dst_file
lcdp [-R] src_file ... dst_directory

options

  • -R recursive copy

  • --dry-run show what it would do

  • --verbose print what it's doing

Like cp

  • with just 2 arguments, copies a single file from src to dst

  • with -R if the source ends with / it copies the contents of source

    In other words assume you have

    +-abc
    | +-def.txt
    | +-ghi.txt
    +-xyz

    then

    ldcp -R abc xyz

    results in

    +-abc
    | +-def.txt
    | +-ghi.txt
    xyz
      +--abc
         +--def.txt
         +--ghi.txt

    where as

    ldcp -R abc/ xyz

    results in

    +-abc
    | +-def.txt
    | +-ghi.txt
    +-xyz
      +--def.txt
      +--ghi.txt

    if xyz does not exist

    then

    ldcp -R abc xyz

    results in

    +-abc
    | +-def.txt
    | +-ghi.txt
    xyz
      +--def.txt
      +--ghi.txt

    where as

    ldcp -R abc/ xyz

    results in

    +-abc
    | +-def.txt
    | +-ghi.txt
    +-xyz
      +--def.txt
      +--ghi.txt

API

const ldcp = require('ldcp');

ldcp(['src'], 'dst', {recurse: true});

or

const fs = require('fs');
const ldcp = require('ldcp');

const api = {
  copyFileSync(...args) { return fs.copyFileSync(...args) },
  mkdirSync(...args) { return fs.mkdirSync(...args); },
  statSync(...args) { return fs.statSync(...args); },
  readdirSync(...args) { return fs.readdirSync(...args); },
  log(..args) { console.log(...args); },
};
ldcp(['src'], 'dst', {recurse: true}, api);