New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

renames

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

renames

cli-renames

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

img

renames

A good helper for batch renaming files.

Install

$ npm i -g renames

Usage

$ renames <beforePatten> <afterPatten> --dir <dir>          # preview
$ renames <beforePatten> <afterPatten> --dir <dir>  --write # write to disk

example 1:

Suppose you now have the following directory structure:

├─ components
│  ├─ ListPost.tsx
│  ├─ NavBar.tsx
│  ├─ ToggleTheme.tsx

Just run renames and it will rename all files in the directory to match the new file name.

renames "([A-Z])([a-z]*)([A-Z])([a-z]*).tsx" "([a-z])([a-z]*)-([a-z])([a-z]*).tsx" --dir ./components --write
├─ components
│  ├─ list-post.tsx
│  ├─ nav-bar.tsx
│  ├─ toggle-theme.tsx

example 2:

├─ tests
│  ├─ sort_test.js
│  ├─ match_test.js
│  ├─ index_test.js
renames "([a-z]*)_([a-z]*).js" "([a-z]*).([a-z]*).ts" --dir ./tests --write
├─ tests
│  ├─ sort.test.ts
│  ├─ match.test.ts
│  ├─ index.test.ts

example 3:

├─ src
│  ├─ qBar.js
│  ├─ BFoo.js
│  ├─ zBaz.js
'([qB]+)([A-Z])([a-z]*).js' '()([A-Z])([a-z]*).js' --dir src --write
├─ src
│  ├─ ar.js
│  ├─ Foo.js
│  ├─ zBaz.js

Base patten rule

pattendescription
()match an expression
[a-z]match a lowercase letter
[A-Z]match an uppercase letter
*match any number of characters
?match zero or one character
+match one or more characters

Notice

In the <beforePatten> and <afterPatten>, the number of () must be equal.

Such as if you want:

├─ src
│  ├─ sLog.ts
│  ├─ qWitch.ts
│  ├─ Index.ts
│  ├─ App.ts

Transform to:

├─ src
│  ├─ Log.ts
│  ├─ Witch.ts
│  ├─ Index.ts
│  ├─ App.ts

You should run:

- renames '([a-z]?)([A-Z])([a-z]*).js' '([A-Z])([a-z]*).js --dir ./src --write    // ❌
+ renames '([a-z]?)([A-Z])([a-z]*).js' '()([A-Z])([a-z]*).js' --dir ./src --write // ✅

Keywords

cli

FAQs

Package last updated on 20 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts