querysub 0.277.0 → 0.279.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.277.0",
3
+ "version": "0.279.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -4,6 +4,7 @@ import { runPromise } from "../functional/runCommand";
4
4
  import { measureWrap } from "socket-function/src/profiling/measure";
5
5
  import fs from "fs";
6
6
  import os from "os";
7
+ import path from "path";
7
8
  export async function getGitURLLive(gitDir = ".") {
8
9
  return (await runPromise(`git remote get-url origin`, { cwd: gitDir })).trim();
9
10
  }
@@ -24,15 +25,22 @@ export async function commitAndPush(config: {
24
25
  gitDir: string;
25
26
  message: string;
26
27
  }) {
27
- // Not for security, just so we can commit messages with special characters or newlines...
28
- function escapeArg(message: string) {
29
- return message.replaceAll("\\", "\\\\")
30
- .replaceAll('"', '\\"')
31
- .replaceAll("\n", "\\n");
28
+ // Use a file to handle newlines, etc
29
+ const tempFile = path.join(os.tmpdir(), `commit-message-${Date.now()}-${Math.random().toString(36).substr(2, 9)}.txt`);
30
+
31
+ try {
32
+ await fs.promises.writeFile(tempFile, config.message, 'utf8');
33
+ await runPromise(`git add --all`, { cwd: config.gitDir });
34
+ await runPromise(`git commit -F "${tempFile}"`, { cwd: config.gitDir });
35
+ await runPromise(`git push`, { cwd: config.gitDir });
36
+ } finally {
37
+ // Clean up temporary file
38
+ try {
39
+ await fs.promises.unlink(tempFile);
40
+ } catch {
41
+ // Ignore cleanup errors
42
+ }
32
43
  }
33
- await runPromise(`git add --all`, { cwd: config.gitDir });
34
- await runPromise(`git commit -m "${escapeArg(config.message)}"`, { cwd: config.gitDir });
35
- await runPromise(`git push`, { cwd: config.gitDir });
36
44
  }
37
45
 
38
46
  export async function getGitRefInfo(config: {