simple-git
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@kwsites/file-exists | 1.1.1 | 4.85 kB | MIT | prod | |
@kwsites/promise-deferred | 1.1.1 | 2.5 kB | MIT | prod | |
debug | 4.3.4 | 12.94 kB | MIT | prod |
Simple-git is a lightweight npm package that provides a simple interface for running git
commands in any Node.js application. It streamlines interaction with the git
CLI, allowing developers to execute git commands programmatically within their applications. Simple-git requires git to be installed and available to be called using the command git
.
Using simple-git starts with installing the package via your preferred package manager. With npm, the installation command is npm install simple-git
, while with yarn, it's yarn add simple-git
.
Once simple-git is installed, it can be incorporated in JavaScript applications using either Common JS or ES Module imports. Here are some usage examples in both JavaScript and TypeScript:
In JavaScript, using Common JS:
// importing the library; main export is a function
const simpleGit = require('simple-git');
simpleGit().clean(simpleGit.CleanOptions.FORCE);
// or use named properties
const { simpleGit, CleanOptions } = require('simple-git');
simpleGit().clean(CleanOptions.FORCE);
Or in JavaScript, as an ES Module:
import { simpleGit, CleanOptions } from 'simple-git';
simpleGit().clean(CleanOptions.FORCE);
And in TypeScript, utilizing the bundled type definitions:
import { simpleGit, SimpleGit, CleanOptions } from 'simple-git';
const git: SimpleGit = simpleGit().clean(CleanOptions.FORCE);
You can take advantage of its APIs for various git commands as demonstrated above, and chain tasks together for flexible configurations and workflows.
The comprehensive documentation for simple-git can be found on its GitHub repository at https://github.com/steveukx/git-js.git
. There you can find a detailed readme file, including instructions on installation, usage, and API references. Additionally, the repository provides documentation for configuring various plugins, handling task promises and callbacks, and understanding task responses.