Skip to content

Commit 2f021e7

Browse files
committedJun 25, 2022
Update documentation for importing best-practice.
1 parent aef5f67 commit 2f021e7

9 files changed

+24
-13
lines changed
 

‎.changeset/skipping-gold-skips.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@simple-git/test-es-module-consumer": patch
3+
"@simple-git/teset-javascript-consumer": patch
4+
"@simple-git/test-typescript-consumer": patch
5+
"@simple-git/test-typescript-esm-consumer": patch
6+
"simple-git": minor
7+
---
8+
9+
Support for importing as an ES module with TypeScript moduleResolution `node16` or newer by adding
10+
`simpleGit` as a named export.

‎docs/DEBUG-LOGGING-GUIDE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ simpleGit().init().then(() => console.log('DONE'));
2121

2222
```typescript
2323
import debug from 'debug';
24-
import simpleGit from 'simple-git';
24+
import { simpleGit } from 'simple-git';
2525

2626
debug.enable('simple-git,simple-git:*');
2727
simpleGit().init().then(() => console.log('DONE'));

‎docs/LEGACY_NODE_VERSIONS.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Legacy Node Versions
33

44
From `v3.x`, `simple-git` will drop support for `node.js` version 10 or below.
5+
From `v3.8`, `simple-git` will no longer be tested against node version 12 or below.
56

67
To use in lower versions of node, ensure you are also including the necessary polyfills from `core-js`:
78

‎docs/PLUGIN-COMPLETION-DETECTION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ From version `2.46.0` onwards, you can configure this behaviour by using the
1212
`completion` plugin:
1313

1414
```typescript
15-
import simpleGit, { SimpleGit } from 'simple-git';
15+
import { simpleGit, SimpleGit } from 'simple-git';
1616

1717
const git: SimpleGit = simpleGit({
1818
completion: {

‎docs/PLUGIN-ERRORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ detection plugin is the original error. Either return that error directly to all
1313
task's error handlers, or implement your own error detection as below:
1414

1515
```typescript
16-
import simpleGit from 'simple-git';
16+
import { simpleGit } from 'simple-git';
1717

1818
const git = simpleGit({
1919
errors(error, result) {

‎docs/PLUGIN-PROGRESS-EVENTS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
To receive progress updates, pass a `progress` configuration option to the `simpleGit` instance:
44

55
```typescript
6-
import simpleGit, { SimpleGit, SimpleGitProgressEvent } from 'simple-git';
6+
import { simpleGit, SimpleGit, SimpleGitProgressEvent } from 'simple-git';
77

88
const progress = ({method, stage, progress}: SimpleGitProgressEvent) => {
99
console.log(`git.${method} ${stage} stage ${progress}% complete`);

‎docs/PLUGIN-TIMEOUT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ To handle the case where the underlying `git` processes appear to hang, configur
55
`stdOut` or `stdErr` streams before sending a `SIGINT` kill message.
66

77
```typescript
8-
import simpleGit, { GitPluginError, SimpleGit, SimpleGitProgressEvent } from 'simple-git';
8+
import { simpleGit, GitPluginError, SimpleGit, SimpleGitProgressEvent } from 'simple-git';
99

1010
const git: SimpleGit = simpleGit({
1111
baseDir: '/some/path',

‎examples/git-change-working-directory.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ when it is created by using the `baseDir` property:
55

66
```typescript
77
import { join } from 'path';
8-
import simpleGit from 'simple-git';
8+
import { simpleGit } from 'simple-git';
99

1010
const git = simpleGit({ baseDir: join(__dirname, 'repos') });
1111
```
@@ -14,7 +14,7 @@ Or explicitly set the working directory at some later time, for example after cl
1414

1515
```typescript
1616
import { join } from 'path';
17-
import simpleGit, { SimpleGit } from 'simple-git';
17+
import { simpleGit, SimpleGit } from 'simple-git';
1818

1919
const remote = `https://github.com/steveukx/git-js.git`;
2020
const target = join(__dirname, 'repos', 'git-js');
@@ -29,7 +29,7 @@ are treated as an atomic operation. To rewrite this using separate `async/await`
2929

3030
```typescript
3131
import { join } from 'path';
32-
import simpleGit, { SimpleGit } from 'simple-git';
32+
import { simpleGit, SimpleGit } from 'simple-git';
3333

3434
const remote = `https://github.com/steveukx/git-js.git`;
3535
const target = join(__dirname, 'repos', 'git-js');

‎simple-git/readme.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@ const simpleGit = require('simple-git');
3030
simpleGit().clean(simpleGit.CleanOptions.FORCE);
3131

3232
// or use named properties
33-
const {default: simpleGit, CleanOptions} = require('simple-git');
33+
const {simpleGit, CleanOptions} = require('simple-git');
3434
simpleGit().clean(CleanOptions.FORCE);
3535
```
3636

3737
Include into your JavaScript app as an ES Module:
3838

3939
```javascript
40-
import simpleGit, { CleanOptions } from 'simple-git';
40+
import { simpleGit, CleanOptions } from 'simple-git';
4141

4242
simpleGit().clean(CleanOptions.FORCE);
4343
```
4444

4545
Include in a TypeScript app using the bundled type definitions:
4646

4747
```typescript
48-
import simpleGit, { SimpleGit, CleanOptions } from 'simple-git';
48+
import { simpleGit, SimpleGit, CleanOptions } from 'simple-git';
4949

5050
const git: SimpleGit = simpleGit().clean(CleanOptions.FORCE);
5151
```
@@ -55,7 +55,7 @@ const git: SimpleGit = simpleGit().clean(CleanOptions.FORCE);
5555
Configure each `simple-git` instance with a properties object passed to the main `simpleGit` function:
5656

5757
```typescript
58-
import simpleGit, { SimpleGit, SimpleGitOptions } from 'simple-git';
58+
import { simpleGit, SimpleGit, SimpleGitOptions } from 'simple-git';
5959

6060
const options: Partial<SimpleGitOptions> = {
6161
baseDir: process.cwd(),
@@ -580,7 +580,7 @@ if (mergeSummary.failed) {
580580
With typed errors available in TypeScript
581581

582582
```typescript
583-
import simpleGit, { MergeSummary, GitResponseError } from 'simple-git';
583+
import { simpleGit, MergeSummary, GitResponseError } from 'simple-git';
584584
try {
585585
const mergeSummary = await simpleGit().merge();
586586
console.log(`Merged ${ mergeSummary.merges.length } files`);

0 commit comments

Comments
 (0)
Please sign in to comment.