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

@unixcompat/mv.js

v2.0.0

Published

Moves or renames files or directories like the "mv" command.

Downloads

23

Readme

mv.js

Latest version Dependency status Coverage

Moves or renames files or directories like the mv command.

There are multi-platform file-system commands compatible with mv from UN*X implemented for Node.js in JavaScript, like renamer, but they have different interface and different behaviour than the mv command. Instead of reusing the knowledge of the mv command, you would have to learn their new interface. This project aims to provide the well-known interface of the mv command.

This package offers only command-line interface, because programmatic interface is provided by rename from node:fs. See also other commands compatible with their counterparts from UN*X - cat.js, cp.js, ln.js, mkdir.js and rm.js.

Synopsis

The following scripts from package.json won't work on Windows:

rm -rf dist
mkdir -p dist
cat src/umd-prolog.txt src/code.js src/umd-epilog.txt > dist/index.umd.js
cp src/index.d.ts dist
mv LICENSE doc
ln -s ../src src

Replace them with the following ones, which run on any operating system which is supported by Node.js:

rm-j -rf dist
mkdir-j -p dist
cat-j src/umd-prolog.txt src/code.js src/umd-epilog.txt > dist/index.umd.js
cp-j src/index.d.ts dist
mv-j LICENSE doc
ln-j -s ../src src

Notice that the only difference is the suffix .js behind the command names.

Installation

This module can be installed in your project using NPM, PNPM or Yarn. Make sure, that you use Node.js version 16.15 or newer.

$ npm i -D @unixcompat/mv.js
$ pnpm i -D @unixcompat/mv.js
$ yarn add -D @unixcompat/mv.js

Command-line Interface

See also man mv for the original POSIX documentation or for the extended Linux implementation.

Usage: mv-j [-Dfnv] [--] src... dest

Options:
  -c|--cwd <dir>              directory to start looking for the source files
  -D|--dry-run                only print paths of source files or directories
  -f|--force                  removes the destination if not writable
  -n|--no-clobbering          prevents accidentally overwriting any files
  -v|--verbose                print path of each copied file or directory
  -V|--version                print version number
  -h|--help                   print usage instructions

Examples:
  $ mv-j prog.js prog.bak
  $ mv-j jones smith /home/nick/clients

Differences

The following options are specific to this command:

-D|--dry-run    only print path of each file or directory
-c|--cwd <dir>  directory to start looking for the source files

Also, the arguments may be BASH patterns. The pattern matching will ignore symbolic links. The argument -c|--cwd will be used only as a base directory to expand the BASH patterns in.

The following options from the POSIX version are not supported:

-i    write a prompt to standard error before copying to any existing
      destination file. If the response from the standard input is
      affirmative, the copy shall be attempted; otherwise, it shall not.

The following options from the Linux version are not supported:

--backup[=CONTROL]
      make a backup of each existing destination file
-b    like --backup but does not accept an argument
-i, --interactive
      prompt before overwrite
--strip-trailing-slashes
      remove any trailing slashes from each SOURCE argument
-S, --suffix=SUFFIX
      override the usual backup suffix
-t, --target-directory=DIRECTORY
      move all SOURCE arguments into DIRECTORY
-T, --no-target-directory
      treat DEST as a normal file
-u, --update
      move only when the SOURCE file is newer than the
      destination file or when the destination file is missing
-Z, --context
      set SELinux security context of destination file to
      default type

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using npm test.

License

Copyright (c) 2023 Ferdinand Prantl

Licensed under the MIT license.