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

rectify-name

v3.0.0

Published

A simple npm package rectifies all file names according to provided case extension.

Downloads

5

Readme

logo A simple npm package rectifies all file names according to provided case extension.

📥 Rectify files with the help of npx

npx rectify-name help
# or
npx rectify-name <options> [args]

📦 Install with the help of npm or yarn

# Use -g or global if you want to be install package as a CLI package.
npm install -g rectify-name
# or
yarn global add rectify-name

📑 Use as a CLI Package

The options and args provided by the rectify-name package are below mentioned. | Options(flags) | Supported args default | Options Description | | - | - | - | | -d, --directory | directory-path as string "./" | Rectify given directory files, if a directory exists. | | -c, --case | case-type "lower-case" | Rectify pwd files to a given case-type. | | --caps | | Apply capitalization, if case-type is supported. | | -h, --help, help | | Get help manual | | -v, --version, version | | Get the current package version |

🧪 CLI Example

rectify-name -d "./test" -c "camel-case" --caps

In the above example is an option -d to set the directory path, -c is used to set the case-type and last option --caps is said to capitalize the camelCase type to CamelCase.

📔 case-type

Below case-type will be supported by the rectify-name package, as the case-type args.

| case-type | Support capitalization | Example | Capitalization | | - | - | - | - | | lower-case | | "my file.txt", "test file.txt" | | | camle-case | YES | "myFile.txt", "testFile.txt" | "MyFile.txt", "TestFile.txt" | | capital-case | | "My File.txt", "Test File.txt" | | | constant-case | | "MY_FILE.txt", "TEST_FILE.txt" | | | kebab-case | YES | "my-file.txt", "test-file.txt" | "My-File.txt", "Test-File.txt" | | pascal-case | | "MyFile.txt", "TestFile.txt" | | | snake-case | YES | "my_file.txt", "test_file.txt" | "My_File.txt", "Test_File.txt" |

📄 Use as a Package Dependency

This package is also capable to use as a dependency package with the help of importing two method.

// CommonJS
const { renameFile, reflectRenameOnSystem } = require("rectify-name");

// ES6
import { renameFile, reflectRenameOnSystem } from "rectify-name";

📝 renameFile

The renameFile method takes two parameters, the first is the options object and the second is the file name array. and returns an object with the actual filename and the changed filename.

// dir: name of the directory.
// case: according to the case type table refer to the case-type.
// caps: if the case is supported, then capitalization will work.
const defaultOptions = { dir: './', case: 'lower-case', caps: false };

/* File name array you will get your file name to 
an array with the help of readdir or readdirSync 
method in the fs module in NodeJs. */
const fileNameArray = [
	'blog-1.txt',
	'blog_2.txt',
	'camelCase.txt',
	'Capital Case.txt',
	'CONSTANT_CASE.txt',
	'details file me.js',
	'PascalCase.txt'
];
const actualAndRenamedFiles = renameFile(defaultOptions, fileNameArray);

🗃️ reflectRenameOnSystem

As the name suggests this method will apply to rename files on the system, and it will rename the provided directory files, first argument of this method is the directory path.

// The response provided by the renameFile method is used as the second argument of this method.
const actualAndRenamedFiles = renameFile(defaultOptions, fileNameArray);

// This method does not return anything, you can see the output on the provided path.
reflectRenameOnSystem("./", actualAndRenamedFiles);

Thanks 💻