@codeswriter/netrc-rw
v1.0.0
Published
A type-safe ES6 module to read, write, and manipulate your `.netrc` file with full TypeScript support.
Readme
Description
A type-safe ES6 module to read, write, and manipulate your .netrc file with full TypeScript support.
✨ Features
- 🔒 Type Safety: Full TypeScript definitions for all operations
- 📁 Zero Dependencies: Lightweight and self-contained
📦 Installation
npm install @codeswriter/netrc-rw📖 Usage Examples
Usage
import { NetRC } from "@codeswriter/netrc";
const netrc = new NetRC()
# read
const pass = netrc.host('domain.com').password
# edit
netrc.host('domain.com').password = "passw0rd"
netrc.write()
# add new
netrc.addHost('api.domain.com').password = "otherPassw0rd"
netrc.write()🔧 API Reference
Machine Properties
Each Machine object has these typed properties:
login: string- The username/loginpassword: string- The passwordaccount?: string- Optional account name
📁 File Location
By default, the library uses the standard .netrc file location:
- Unix/Linux/macOS:
~/.netrc - Windows:
%HOME%/_netrc
You can specify a custom file path:
// Use custom netrc file location
const customNetRC = new NetRC('/path/to/custom/netrc/file');
const machine = customNetRC.host('example.com');🧪 Testing
# Run tests
npm test
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
This project is a TypeScript evolution of the original netrc-rw library created by Trey Griffith. It maintains full API compatibility while adding type safety and modern development practices.
Special thanks to Trey Griffith for creating the original netrc-rw library that served as the foundation for this project.
