Skip to content

Commit 1285b95

Browse files
author
Akos Kitta
committed
GH-11: Adjusted the lookup to the latest VS Code.
- [win32]: Use `which` when cannot find Git on the `$PATH`. - Listen on the process' `close` instead of `exit`. - Moved the Windows build to Travis. - Pinned the versions with `yarn.lock`. - Bumped up the dependencies. - New version -> `0.0.2`. Closes #11. Co-authored-by: Alex Tugarev <[email protected]> Co-authored-by: Akos Kitta <[email protected]> Signed-off-by: Akos Kitta <[email protected]>
1 parent 985e5da commit 1285b95

11 files changed

+1009
-150
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
22
node_modules
33
lib
4-
*.log
4+
*.log
5+
package-lock.json

.travis.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
language: node_js
22

3+
env:
4+
# Fix Windows build never ending in Travis CI
5+
# https://travis-ci.community/t/timeout-after-build-finished-and-succeeded/1336
6+
- YARN_GPG=no
7+
38
os:
49
- linux
510
- osx
11+
- windows
612

713
node_js:
8-
- '8'
9-
- '7'
10-
- '6'
14+
- 10
1115

1216
git:
1317
depth: 1
@@ -17,7 +21,7 @@ branches:
1721
- master
1822

1923
install:
20-
- npm i
24+
- yarn
2125

2226
script:
23-
- npm run build && npm run test
27+
- yarn build && yarn test

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# find-git-exec
22
[![Build Status](https://travis-ci.org/TypeFox/find-git-exec.svg?branch=master)](https://travis-ci.org/TypeFox/find-git-exec)
3-
[![Build status](https://ci.appveyor.com/api/projects/status/8x9w27df2bit7jan/branch/master?svg=true)](https://ci.appveyor.com/project/kittaakos/find-git-exec/branch/master)
43

54
A lightweight library for locating the Git executable on the host system.
5+
This library is a stripped down version of the Git discovery logic [implemented and used by VS Code](https://github.com/microsoft/vscode/blob/master/extensions/git/src/git.ts#L50-L141).
66

77
## Install
88
```bash
9-
npm i -S find-git-exec
9+
yarn add find-git-exec
1010
```
1111

1212
## Build
1313
```bash
14-
npm run build
14+
yarn build
1515
```
1616

1717
## Test
1818
```bash
19-
npm run test
19+
yarn test
2020
```
2121

2222
## Example

appveyor.yml

-24
This file was deleted.

mocha.opts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
--require ts-node/register
22
--reporter spec
3-
--watch-extensions ts
3+
--watch-extensions ts

package.json

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
22
"name": "find-git-exec",
3-
"version": "0.0.1-alpha.2",
3+
"version": "0.0.2",
44
"description": "A lightweight library for locating the Git executable on the host system",
55
"keywords": [
66
"git"
77
],
8+
"engines": {
9+
"node": ">=10.11.0 <12"
10+
},
811
"repository": {
912
"type": "git",
1013
"url": "https://github.com/TypeFox/find-git-exec.git"
@@ -27,17 +30,19 @@
2730
"author": "typefox <[email protected]>",
2831
"license": "MIT",
2932
"dependencies": {
30-
"@types/node": "^8.0.26"
33+
"@types/node": "^10.14.22",
34+
"@types/which": "^1.3.2",
35+
"which": "^2.0.1"
3136
},
3237
"devDependencies": {
33-
"@types/chai": "^4.0.4",
34-
"@types/mocha": "^2.2.42",
35-
"chai": "^4.1.2",
36-
"mocha": "^3.5.0",
37-
"rimraf": "^2.6.1",
38-
"ts-node": "^3.3.0",
39-
"tslint": "^5.7.0",
40-
"tslint-no-unused-expression-chai": "0.0.2",
41-
"typescript": "^2.5.2"
38+
"@types/chai": "^4.2.4",
39+
"@types/mocha": "^5.2.7",
40+
"chai": "^4.2.0",
41+
"mocha": "^6.2.2",
42+
"rimraf": "^3.0.0",
43+
"ts-node": "^8.4.1",
44+
"tslint": "^6.0.0-beta0",
45+
"tslint-no-unused-expression-chai": "^0.1.4",
46+
"typescript": "^3.1.3"
4247
}
4348
}

src/find-git-exec.spec.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,27 @@
55

66
import * as fs from 'fs';
77
import { expect } from 'chai';
8-
import findGit from './find-git-exec';
8+
import findGit, { Git } from './find-git-exec';
99

1010
describe('find-git-exec', async () => {
1111

12-
it('find', async () => {
13-
const git = await findGit();
12+
it('find', async function () {
13+
this.timeout(60_000);
14+
const git = await findGit({ hint: undefined, onLookup: (p: string) => console.log(`[TRACE]: Git discovery: ${p}`) });
1415
const { path, version, execPath } = git;
15-
expect(fs.existsSync(path)).to.be.true;
16-
expect(fs.existsSync(execPath)).to.be.true;
17-
expect(version.startsWith('2')).to.be.true;
16+
expect(fs.existsSync(path), `[path]: expected ${path} to exist on the filesystem`).to.be.true;
17+
expect(fs.existsSync(execPath), `[execPath]: expected ${execPath} to exist on the filesystem`).to.be.true;
18+
expect(version.startsWith('2'), `[version]: expected version 2.x was ${version} instead`).to.be.true;
19+
const promises: Array<Promise<Git>> = [];
20+
for (let i = 0; i < 1000; i++) {
21+
promises.push(findGit({ hint: undefined, onLookup: (p: string) => {/* silent */ } }));
22+
}
23+
const results = await Promise.all(promises);
24+
results.forEach(({ version: actualVersion, path: actualPath, execPath: actualExecPath }) => {
25+
expect(actualVersion).to.be.deep.equal(version, `Expected ${version} as 'version', got ${actualPath} instead.`);
26+
expect(actualPath).to.be.deep.equal(path, `Expected ${path} as 'path', got ${actualPath} instead.`);
27+
expect(actualExecPath).to.be.deep.equal(execPath, `Expected ${path} as 'execPath', got ${actualPath} instead.`);
28+
})
1829
});
1930

2031
});

0 commit comments

Comments
 (0)