GitNifty: Your Git Automation Sidekick for Node.js
Tired of wrestling with Git in your Node.js scripts? Shelling out to Git, handling edge cases, escaping strings, and parsing messy output can be a nightmare. GitNifty solves that with a robust, promise-based Git utility built in TypeScript - designed for clean, automation-ready workflows with zero dependencies.
Why GitNifty?
GitNifty streamlines Git operations for Node.js developers building dev tools, CI/CD pipelines, or custom CLIs. It lets you:
- Programmatically manage Git repositories
- Ditch brittle shell scripts
- Write readable, async-first code
- Create reliable workflows with confidence
It’s Git, made delightfully simple.
Installation
npm install gitnifty
# or
yarn add gitnifty
Quick Example
import { Git } from "gitnifty";
const git = new Git({ cwd: "/path/to/repo" });
const username = await git.getUserName(); // e.g., "Alice Doe"
const branch = await git.getCurrentBranchName(); // e.g., "main"
const isClean = await git.isWorkingDirClean(); // true or false
For scripting:
async function main() {
const git = new Git();
await git.init();
await git.add();
const name = await git.getUserName();
console.log(`Git User: ${name}`);
}
main();
Features
- Promise-based API: Async/await for seamless integration
- Smart Methods: Access user info, branch names, and repo status
- TypeScript Support: Full type safety out of the box
- Zero Dependencies: Lightweight and reliable
- Error Handling: Gracefully manages misconfigurations
- Automation-Ready: Perfect for CLI tools and CI pipelines
Experimental Feature: Chainable Commands
We’re exploring chainable Git commands for fluid workflows:
await git.add().commit("chore: update lockfile").push();
What do you think? Should add
, commit
, and push
be chainable? Share your feedback on GitHub!
Full API
Explore the full API documentation for commands like:
getUserName()
getUserEmail()
getCurrentBranchName()
isWorkingDirClean()
-
init()
,add()
,commit(message)
, and more
Requirements
- Node.js v18+
- Git installed and available in
$PATH
- TypeScript (optional, but fully supported)
What’s Next?
We’re working on chainable commands (add
, commit
, push
, restore
) to make Git pipelines even smoother:
await git.add().commit("fix: apply patch").push();
Got thoughts on this? Drop them on GitHub or comment below!
We Want Your Input!
GitNifty is evolving, and your feedback shapes its future:
- What features do you need?
- Are there gaps we should address?
- Is the API intuitive?
Try GitNifty today and let us know how it works for you! Star us on GitHub or share your thoughts below.
Top comments (0)