workspace-tools 0.19.0 → 0.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/git.d.ts CHANGED
@@ -1,8 +1,11 @@
1
+ /// <reference types="node" />
2
+ import { SpawnSyncOptions } from "child_process";
1
3
  declare type ProcessOutput = {
2
4
  stderr: string;
3
5
  stdout: string;
4
6
  success: boolean;
5
7
  };
8
+ /** Observes the git operations called from `git()` or `gitFailFast()` */
6
9
  declare type GitObserver = (args: string[], output: ProcessOutput) => void;
7
10
  /**
8
11
  * Adds an observer for the git operations, e.g. for testing
@@ -10,19 +13,13 @@ declare type GitObserver = (args: string[], output: ProcessOutput) => void;
10
13
  */
11
14
  export declare function addGitObserver(observer: GitObserver): void;
12
15
  /**
13
- * Runs git command - use this for read only commands
16
+ * Runs git command - use this for read-only commands
14
17
  */
15
- export declare function git(args: string[], options?: {
16
- cwd: string;
17
- maxBuffer?: number;
18
- }): ProcessOutput;
18
+ export declare function git(args: string[], options?: SpawnSyncOptions): ProcessOutput;
19
19
  /**
20
- * Runs git command - use this for commands that makes changes to the file system
20
+ * Runs git command - use this for commands that make changes to the filesystem
21
21
  */
22
- export declare function gitFailFast(args: string[], options?: {
23
- cwd: string;
24
- maxBuffer?: number;
25
- }): void;
22
+ export declare function gitFailFast(args: string[], options?: SpawnSyncOptions): void;
26
23
  export declare function getUntrackedChanges(cwd: string): string[];
27
24
  export declare function fetchRemote(remote: string, cwd: string): void;
28
25
  export declare function fetchRemoteBranch(remote: string, remoteBranch: string, cwd: string): void;
package/lib/git.js CHANGED
@@ -16,11 +16,11 @@ function gitError(message, e) {
16
16
  return new Error(message);
17
17
  }
18
18
  /**
19
- * A maxBuffer override globally for all git operations
20
- * Bumps up the default to 500MB as opposed to the 1MB
21
- * Override this value with "GIT_MAX_BUFFER" environment variable
19
+ * A global maxBuffer override for all git operations.
20
+ * Bumps up the default to 500MB instead of 1MB.
21
+ * Override this value with the `GIT_MAX_BUFFER` environment variable.
22
22
  */
23
- const MaxBufferOption = process.env.GIT_MAX_BUFFER ? parseInt(process.env.GIT_MAX_BUFFER) : 500 * 1024 * 1024;
23
+ const defaultMaxBuffer = process.env.GIT_MAX_BUFFER ? parseInt(process.env.GIT_MAX_BUFFER) : 500 * 1024 * 1024;
24
24
  const observers = [];
25
25
  let observing;
26
26
  /**
@@ -32,25 +32,15 @@ function addGitObserver(observer) {
32
32
  }
33
33
  exports.addGitObserver = addGitObserver;
34
34
  /**
35
- * Runs git command - use this for read only commands
35
+ * Runs git command - use this for read-only commands
36
36
  */
37
37
  function git(args, options) {
38
- const results = (0, child_process_1.spawnSync)("git", args, Object.assign({ maxBuffer: MaxBufferOption }, options));
39
- let output;
40
- if (results.status === 0) {
41
- output = {
42
- stderr: results.stderr.toString().trimRight(),
43
- stdout: results.stdout.toString().trimRight(),
44
- success: true,
45
- };
46
- }
47
- else {
48
- output = {
49
- stderr: results.stderr.toString().trimRight(),
50
- stdout: results.stdout.toString().trimRight(),
51
- success: false,
52
- };
53
- }
38
+ const results = (0, child_process_1.spawnSync)("git", args, Object.assign({ maxBuffer: defaultMaxBuffer }, options));
39
+ const output = {
40
+ stderr: results.stderr.toString().trimRight(),
41
+ stdout: results.stdout.toString().trimRight(),
42
+ success: results.status === 0
43
+ };
54
44
  // notify observers, flipping the observing bit to prevent infinite loops
55
45
  if (!observing) {
56
46
  observing = true;
@@ -63,7 +53,7 @@ function git(args, options) {
63
53
  }
64
54
  exports.git = git;
65
55
  /**
66
- * Runs git command - use this for commands that makes changes to the file system
56
+ * Runs git command - use this for commands that make changes to the filesystem
67
57
  */
68
58
  function gitFailFast(args, options) {
69
59
  const gitResult = git(args, options);
@@ -85,7 +75,7 @@ function getUntrackedChanges(cwd) {
85
75
  if (changes.length == 0) {
86
76
  return [];
87
77
  }
88
- const lines = changes.split(/\0/).filter((line) => line) || [];
78
+ const lines = changes.split(/[\r\n]+/).filter((line) => line) || [];
89
79
  const untracked = [];
90
80
  for (let i = 0; i < lines.length; i++) {
91
81
  const line = lines[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workspace-tools",
3
- "version": "0.19.0",
3
+ "version": "0.19.3",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,6 +10,8 @@
10
10
  "types": "lib/index.d.ts",
11
11
  "scripts": {
12
12
  "build": "tsc",
13
+ "build:docs": "typedoc src/index.ts",
14
+ "release:docs": "typedoc src/index.ts && gh-pages -d docs",
13
15
  "change": "beachball change",
14
16
  "checkchange": "beachball check",
15
17
  "release": "beachball publish -y",
@@ -38,6 +40,8 @@
38
40
  "jest": "^25.0.0",
39
41
  "tmp": "^0.2.1",
40
42
  "ts-jest": "^25.5.1",
41
- "typescript": "^4.5.4"
43
+ "typedoc": "^0.22.15",
44
+ "typescript": "^4.5.4",
45
+ "gh-pages": "^3.2.3"
42
46
  }
43
47
  }