@npmcli/git
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -142,3 +142,3 @@ // The goal here is to minimize both git workload and | ||
.then(() => git(['rev-parse', '--revs-only', 'HEAD'])) | ||
.then(stdout => stdout.trim()) | ||
.then(({stdout}) => stdout.trim()) | ||
} |
@@ -5,2 +5,5 @@ module.exports = { | ||
spawn: require('./spawn.js'), | ||
is: require('./is.js'), | ||
find: require('./find.js'), | ||
isClean: require('./is-clean.js'), | ||
} |
@@ -21,5 +21,5 @@ const pinflight = require('promise-inflight') | ||
spawn(['ls-remote', repo], opts) | ||
.then(stdout => linesToRevs(stdout.trim().split('\n'))) | ||
.then(({stdout}) => linesToRevs(stdout.trim().split('\n'))) | ||
.then(revs => (revsCache.set(repo, revs), revs)) | ||
) | ||
} |
@@ -27,3 +27,2 @@ const spawn = require('@npmcli/promise-spawn') | ||
}) | ||
.then(({stdout}) => stdout) | ||
}, opts.retry !== null && opts.retry !== undefined ? opts.retry : { | ||
@@ -30,0 +29,0 @@ retries: opts.fetchRetries || 2, |
{ | ||
"name": "@npmcli/git", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -12,3 +12,4 @@ # @npmcli/git | ||
```js | ||
git.clone(['git://foo/bar.git']) // clone a repo | ||
const git = require('@npmcli/git') | ||
git.clone('git://foo/bar.git', 'some-branch', 'some-path', opts) // clone a repo | ||
.then(() => git.spawn(['checkout', 'some-branch'], {cwd: 'bar'})) | ||
@@ -20,5 +21,5 @@ .then(() => git.spawn(['you get the idea'])) | ||
All methods take an options object. Options are described below. | ||
Most methods take an options object. Options are described below. | ||
### `git.spawn(args, opts = {})` -> Promise | ||
### `git.spawn(args, opts = {})` | ||
@@ -34,7 +35,15 @@ Launch a `git` subprocess with the arguments specified. | ||
### `git.clone(repo, ref = 'HEAD', target = null, opts = {})` | ||
Return value is a `Promise` that resolves to a result object with `{cmd, | ||
args, code, signal, stdout, stderr}` members, or rejects with an error with | ||
the same fields, passed back from | ||
[`@npmcli/promise-spawn`](http://npm.im/@npmcli/promise-spawn). | ||
### `git.clone(repo, ref = 'HEAD', target = null, opts = {})` -> `Promise<sha String>` | ||
Clone the repository into `target` path (or the default path for the name | ||
of the repository), checking out `ref`. | ||
Return value is the sha of the current HEAD in the locally cloned | ||
repository. | ||
In lieu of a specific `ref`, you may also pass in a `spec` option, which is | ||
@@ -61,3 +70,3 @@ a [`npm-package-arg`](http://npm.im/npm-package-arg) object for a `git` | ||
### `git.revs(repo, opts = {})` | ||
### `git.revs(repo, opts = {})` -> `Promise<rev doc Object>` | ||
@@ -108,2 +117,27 @@ Fetch a representation of all of the named references in a given | ||
### `git.is(path)` -> `Promise<Boolean>` | ||
Resolve to `true` if the path argument refers to the root of a git | ||
repository. | ||
It does this by looking for a file in `${path}/.git/index`, which is not an | ||
airtight indicator, but at least avoids being fooled by an empty directory | ||
or a file named `.git`. | ||
### `git.find(path)` -> `Promise<String | null>` | ||
Given a path, walk up the file system tree until a git repo working | ||
directory is found. Since this calls `stat` a bunch of times, it's | ||
probably best to only call it if you're reasonably sure you're likely to be | ||
in a git project somewhere. | ||
Resolves to `null` if not in a git project. | ||
### `git.isClean(path, opts = {})` -> `Promise<Boolean>` | ||
Return true if in a git dir, and that git dir is free of changes. This | ||
will resolve `true` if the git working dir is clean, or `false` if not, and | ||
reject if the path is not within a git directory or some other error | ||
occurs. | ||
## OPTIONS | ||
@@ -110,0 +144,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20010
16
395
155
4