@altano/repository-tools 2.0.3 → 2.0.5

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/dist/exec.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { exec, execFile, execFileSync, execSync } from "child_process";
2
-
3
2
  //#region src/exec.d.ts
4
3
  declare const execAsync: typeof exec.__promisify__;
5
4
  declare const execFileAsync: typeof execFile.__promisify__;
package/dist/exec.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"exec.js","names":[],"sources":["../src/exec.ts"],"sourcesContent":["import { exec, execFile } from \"child_process\";\nimport { promisify } from \"node:util\";\n\nexport { execSync, execFileSync } from \"child_process\";\n\nexport const execAsync: typeof exec.__promisify__ = promisify(exec);\nexport const execFileAsync: typeof execFile.__promisify__ = promisify(execFile);\n"],"mappings":";;;;AAKA,MAAa,YAAuC,UAAU,KAAK;AACnE,MAAa,gBAA+C,UAAU,SAAS"}
1
+ {"version":3,"file":"exec.js","names":[],"sources":["../src/exec.ts"],"sourcesContent":["import { exec, execFile } from \"child_process\";\nimport { promisify } from \"node:util\";\n\nexport { execSync, execFileSync } from \"child_process\";\n\nexport const execAsync: typeof exec.__promisify__ = promisify(exec);\nexport const execFileAsync: typeof execFile.__promisify__ = promisify(execFile);\n"],"mappings":";;;;AAKA,MAAa,YAAuC,UAAU,IAAI;AAClE,MAAa,gBAA+C,UAAU,QAAQ"}
@@ -1,9 +1,9 @@
1
1
  //#region src/findRoot.d.ts
2
2
  /**
3
- * Find the root path of the repository containing the given directory.
4
- *
5
- * @returns null if not found or the path of the repository root as a string
6
- */
3
+ * Find the root path of the repository containing the given directory.
4
+ *
5
+ * @returns null if not found or the path of the repository root as a string
6
+ */
7
7
  declare function findRoot(directory: string): Promise<string | null>;
8
8
  //#endregion
9
9
  export { findRoot };
@@ -1 +1 @@
1
- {"version":3,"file":"findRoot.js","names":[],"sources":["../src/findRoot.ts"],"sourcesContent":["import { repositoryExec } from \"./repositoryCommand.js\";\n\nasync function findGitRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nasync function findSaplingRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nasync function findMercurialRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nasync function findSubversionRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport async function findRoot(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): Promise<string | null> {\n for (const method of findMethods) {\n try {\n const result = await method(directory);\n /* v8 ignore if */\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,eAAe,YAAY,WAAoC;AAC7D,QAAO,eAAe,WAAW,OAAO;EACtC;EACA;EACA;EACD,CAAC;;AAGJ,eAAe,gBAAgB,WAAoC;AACjE,QAAO,eAAe,WAAW,MAAM,CAAC,WAAW,OAAO,CAAC;;AAG7D,eAAe,kBAAkB,WAAoC;AACnE,QAAO,eAAe,WAAW,MAAM,CAAC,WAAW,OAAO,CAAC;;AAG7D,eAAe,mBAAmB,WAAoC;AACpE,QAAO,eAAe,WAAW,OAAO;EAAC;EAAQ;EAAe;EAAU,CAAC;;AAI7E,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACD;;;;;;AAOD,eAAsB,SAIpB,WACwB;AACxB,MAAK,MAAM,UAAU,YACnB,KAAI;EACF,MAAM,SAAS,MAAM,OAAO,UAAU;;AAEtC,MAAI,UAAU,QAAQ,WAAW,GAC/B,QAAO;UAEF,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAElD,OAAM,IAAI,MAAM,iCAAiC,YAAY;;AAInE,QAAO"}
1
+ {"version":3,"file":"findRoot.js","names":[],"sources":["../src/findRoot.ts"],"sourcesContent":["import { repositoryExec } from \"./repositoryCommand.js\";\n\nasync function findGitRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nasync function findSaplingRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nasync function findMercurialRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nasync function findSubversionRoot(directory: string): Promise<string> {\n return repositoryExec(directory, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport async function findRoot(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): Promise<string | null> {\n for (const method of findMethods) {\n try {\n const result = await method(directory);\n /* v8 ignore if */\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,eAAe,YAAY,WAAoC;CAC7D,OAAO,eAAe,WAAW,OAAO;EACtC;EACA;EACA;CACF,CAAC;AACH;AAEA,eAAe,gBAAgB,WAAoC;CACjE,OAAO,eAAe,WAAW,MAAM,CAAC,WAAW,MAAM,CAAC;AAC5D;AAEA,eAAe,kBAAkB,WAAoC;CACnE,OAAO,eAAe,WAAW,MAAM,CAAC,WAAW,MAAM,CAAC;AAC5D;AAEA,eAAe,mBAAmB,WAAoC;CACpE,OAAO,eAAe,WAAW,OAAO;EAAC;EAAQ;EAAe;CAAS,CAAC;AAC5E;AAGA,MAAM,cAAc;CAClB;CACA;CACA;CACA;AACF;;;;;;AAOA,eAAsB,SAIpB,WACwB;CACxB,KAAK,MAAM,UAAU,aACnB,IAAI;EACF,MAAM,SAAS,MAAM,OAAO,SAAS;;EAErC,IAAI,UAAU,QAAQ,WAAW,IAC/B,OAAO;CAEX,SAAS,GAAY;EACnB,IAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,WAElD,MAAM,IAAI,MAAM,iCAAiC,WAAW;CAEhE;CAEF,OAAO;AACT"}
@@ -1,9 +1,9 @@
1
1
  //#region src/findRootSync.d.ts
2
2
  /**
3
- * Find the root path of the repository containing the given directory.
4
- *
5
- * @returns null if not found or the path of the repository root as a string
6
- */
3
+ * Find the root path of the repository containing the given directory.
4
+ *
5
+ * @returns null if not found or the path of the repository root as a string
6
+ */
7
7
  declare function findRootSync(directory: string): string | null;
8
8
  //#endregion
9
9
  export { findRootSync };
@@ -1 +1 @@
1
- {"version":3,"file":"findRootSync.js","names":[],"sources":["../src/findRootSync.ts"],"sourcesContent":["import { repositoryExecSync } from \"./repositoryCommand.js\";\n\nfunction findGitRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nfunction findSaplingRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nfunction findMercurialRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nfunction findSubversionRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport function findRootSync(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): string | null {\n for (const method of findMethods) {\n try {\n const result = method(directory);\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,SAAS,YAAY,KAAqB;AACxC,QAAO,mBAAmB,KAAK,OAAO;EACpC;EACA;EACA;EACD,CAAC;;AAGJ,SAAS,gBAAgB,KAAqB;AAC5C,QAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,OAAO,CAAC;;AAG3D,SAAS,kBAAkB,KAAqB;AAC9C,QAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,OAAO,CAAC;;AAG3D,SAAS,mBAAmB,KAAqB;AAC/C,QAAO,mBAAmB,KAAK,OAAO;EAAC;EAAQ;EAAe;EAAU,CAAC;;AAI3E,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACD;;;;;;AAOD,SAAgB,aAId,WACe;AACf,MAAK,MAAM,UAAU,YACnB,KAAI;EACF,MAAM,SAAS,OAAO,UAAU;AAChC,MAAI,UAAU,QAAQ,WAAW,GAC/B,QAAO;UAEF,GAAY;AACnB,MAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,UAElD,OAAM,IAAI,MAAM,iCAAiC,YAAY;;AAInE,QAAO"}
1
+ {"version":3,"file":"findRootSync.js","names":[],"sources":["../src/findRootSync.ts"],"sourcesContent":["import { repositoryExecSync } from \"./repositoryCommand.js\";\n\nfunction findGitRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"git\", [\n \"rev-parse\",\n \"--quiet\",\n \"--show-toplevel\",\n ]);\n}\n\nfunction findSaplingRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"sl\", [\"--quiet\", \"root\"]);\n}\n\nfunction findMercurialRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"hg\", [\"--quiet\", \"root\"]);\n}\n\nfunction findSubversionRoot(cwd: string): string {\n return repositoryExecSync(cwd, \"svn\", [\"info\", \"--show-item\", \"wc-root\"]);\n}\n\n// Version control systems to check for. Highest-precedence checks go first.\nconst findMethods = [\n findGitRoot, // most used and fastest check\n findSubversionRoot, // next highest market share\n findSaplingRoot, // much smaller market share, but much faster\n findMercurialRoot, // slow af\n] as const;\n\n/**\n * Find the root path of the repository containing the given directory.\n *\n * @returns null if not found or the path of the repository root as a string\n */\nexport function findRootSync(\n /**\n * The directory path of anything in a version-controlled repository\n */\n directory: string,\n): string | null {\n for (const method of findMethods) {\n try {\n const result = method(directory);\n if (result != null && result !== \"\") {\n return result;\n }\n } catch (e: unknown) {\n if (e instanceof Error && \"code\" in e && e.code === \"ENOTDIR\") {\n // rethrow error when given directory path isn't a directory\n throw new Error(`Given path isn't a directory: ${directory}`);\n }\n }\n }\n return null;\n}\n"],"mappings":";;;AAEA,SAAS,YAAY,KAAqB;CACxC,OAAO,mBAAmB,KAAK,OAAO;EACpC;EACA;EACA;CACF,CAAC;AACH;AAEA,SAAS,gBAAgB,KAAqB;CAC5C,OAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,MAAM,CAAC;AAC1D;AAEA,SAAS,kBAAkB,KAAqB;CAC9C,OAAO,mBAAmB,KAAK,MAAM,CAAC,WAAW,MAAM,CAAC;AAC1D;AAEA,SAAS,mBAAmB,KAAqB;CAC/C,OAAO,mBAAmB,KAAK,OAAO;EAAC;EAAQ;EAAe;CAAS,CAAC;AAC1E;AAGA,MAAM,cAAc;CAClB;CACA;CACA;CACA;AACF;;;;;;AAOA,SAAgB,aAId,WACe;CACf,KAAK,MAAM,UAAU,aACnB,IAAI;EACF,MAAM,SAAS,OAAO,SAAS;EAC/B,IAAI,UAAU,QAAQ,WAAW,IAC/B,OAAO;CAEX,SAAS,GAAY;EACnB,IAAI,aAAa,SAAS,UAAU,KAAK,EAAE,SAAS,WAElD,MAAM,IAAI,MAAM,iCAAiC,WAAW;CAEhE;CAEF,OAAO;AACT"}
@@ -25,14 +25,43 @@ const environment = {
25
25
  svnadmin: {},
26
26
  svnrdump: {}
27
27
  };
28
+ /**
29
+ * Inherited environment variables to drop, per command. The other version
30
+ * control systems have no equivalent of GIT_DIR: they're told which repository
31
+ * to use with a flag, never with the environment.
32
+ */
33
+ const removedEnvironment = {
34
+ git: [
35
+ "GIT_DIR",
36
+ "GIT_WORK_TREE",
37
+ "GIT_COMMON_DIR",
38
+ "GIT_INDEX_FILE",
39
+ "GIT_INDEX_VERSION",
40
+ "GIT_OBJECT_DIRECTORY",
41
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
42
+ "GIT_NAMESPACE",
43
+ "GIT_PREFIX",
44
+ "GIT_QUARANTINE_PATH"
45
+ ],
46
+ hg: [],
47
+ sl: [],
48
+ svn: [],
49
+ svnadmin: [],
50
+ svnrdump: []
51
+ };
52
+ function getEnvironment(command) {
53
+ const result = {
54
+ ...process.env,
55
+ ...environment[command]
56
+ };
57
+ for (const variable of removedEnvironment[command]) delete result[variable];
58
+ return result;
59
+ }
28
60
  async function repositoryExec(cwd, command, args) {
29
61
  return execFileAsync(command, args, {
30
62
  cwd,
31
63
  encoding: "utf8",
32
- env: {
33
- ...process.env,
34
- ...environment[command]
35
- }
64
+ env: getEnvironment(command)
36
65
  }).then(({ stdout, stderr }) => {
37
66
  return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();
38
67
  });
@@ -41,10 +70,7 @@ function repositoryExecSync(cwd, command, args) {
41
70
  return execFileSync(command, args, {
42
71
  cwd,
43
72
  encoding: "utf8",
44
- env: {
45
- ...process.env,
46
- ...environment[command]
47
- }
73
+ env: getEnvironment(command)
48
74
  }).trim();
49
75
  }
50
76
  const createExecForDirectory = (cwd) => repositoryExec.bind(null, cwd);
@@ -1 +1 @@
1
- {"version":3,"file":"repositoryCommand.js","names":[],"sources":["../src/repositoryCommand.ts"],"sourcesContent":["import { execFileAsync, execFileSync } from \"./exec.js\";\nimport {} from \"child_process\";\n\ntype RepositoryCommand = \"git\" | \"hg\" | \"sl\" | \"svn\" | \"svnadmin\" | \"svnrdump\";\n\nconst environment = {\n git: {\n // non-interactive\n GIT_TERMINAL_PROMPT: \"0\",\n // don't use global config\n GIT_CONFIG_GLOBAL: \"/dev/null\",\n GIT_CONFIG_SYSTEM: \"/dev/null\",\n // user config\n GIT_COMMITTER_NAME: \"alan\",\n GIT_COMMITTER_EMAIL: \"alan@example.com\",\n GIT_AUTHOR_NAME: \"alan\",\n GIT_AUTHOR_EMAIL: \"alan@example.com\",\n },\n hg: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n sl: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n svn: {},\n svnadmin: {},\n svnrdump: {},\n} as const satisfies Record<RepositoryCommand, NodeJS.ProcessEnv>;\n\nexport async function repositoryExec(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): Promise<string> {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n return execFileAsync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: {\n ...process.env,\n ...environment[command],\n },\n }).then(({ stdout, stderr }) => {\n // console.timeEnd(msg);\n return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();\n });\n}\n\nexport function repositoryExecSync(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): string {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n const result = execFileSync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: {\n ...process.env,\n ...environment[command],\n },\n }).trim();\n // console.timeEnd(msg);\n return result;\n}\n\nexport const createExecForDirectory = (\n cwd: string,\n): ((command: RepositoryCommand, args: readonly string[]) => Promise<string>) =>\n repositoryExec.bind(null, cwd);\n\n// Not being used.\n// export const createExecSyncForDirectory = (\n// cwd: string,\n// ): ((command: RepositoryCommand, args: readonly string[]) => string) =>\n// repositoryExecSync.bind(null, cwd);\n"],"mappings":";;;AAKA,MAAM,cAAc;CAClB,KAAK;EAEH,qBAAqB;EAErB,mBAAmB;EACnB,mBAAmB;EAEnB,oBAAoB;EACpB,qBAAqB;EACrB,iBAAiB;EACjB,kBAAkB;EACnB;CACD,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;EACR;CACD,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;EACR;CACD,KAAK,EAAE;CACP,UAAU,EAAE;CACZ,UAAU,EAAE;CACb;AAED,eAAsB,eACpB,KACA,SACA,MACiB;AAGjB,QAAO,cAAc,SAAS,MAAM;EAC7B;EACL,UAAU;EACV,KAAK;GACH,GAAG,QAAQ;GACX,GAAG,YAAY;GAChB;EACF,CAAC,CAAC,MAAM,EAAE,QAAQ,aAAa;AAE9B,SAAO,SAAS,QAAQ,OAAO,IAAI,MAAM,OAAO,MAAM,CAAC,CAAC,GAAG,OAAO,MAAM;GACxE;;AAGJ,SAAgB,mBACd,KACA,SACA,MACQ;AAYR,QATe,aAAa,SAAS,MAAM;EACpC;EACL,UAAU;EACV,KAAK;GACH,GAAG,QAAQ;GACX,GAAG,YAAY;GAChB;EACF,CAAC,CAAC,MAAM;;AAKX,MAAa,0BACX,QAEA,eAAe,KAAK,MAAM,IAAI"}
1
+ {"version":3,"file":"repositoryCommand.js","names":[],"sources":["../src/repositoryCommand.ts"],"sourcesContent":["import { execFileAsync, execFileSync } from \"./exec.js\";\nimport {} from \"child_process\";\n\ntype RepositoryCommand = \"git\" | \"hg\" | \"sl\" | \"svn\" | \"svnadmin\" | \"svnrdump\";\n\nconst environment = {\n git: {\n // non-interactive\n GIT_TERMINAL_PROMPT: \"0\",\n // don't use global config\n GIT_CONFIG_GLOBAL: \"/dev/null\",\n GIT_CONFIG_SYSTEM: \"/dev/null\",\n // user config\n GIT_COMMITTER_NAME: \"alan\",\n GIT_COMMITTER_EMAIL: \"alan@example.com\",\n GIT_AUTHOR_NAME: \"alan\",\n GIT_AUTHOR_EMAIL: \"alan@example.com\",\n },\n hg: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n sl: {\n // don't use global config\n HGRCPATH: \"/dev/null\",\n // don't use global config\n HGUSER: \"alan\",\n EMAIL: \"alan@example.com\",\n },\n svn: {},\n svnadmin: {},\n svnrdump: {},\n} as const satisfies Record<RepositoryCommand, NodeJS.ProcessEnv>;\n\n/**\n * Environment variables that pin git to one particular repository, work tree,\n * index, or object store.\n *\n * Git exports several of these before running a hook, so every process a hook\n * spawns inherits them. We always point git at a directory of our choosing\n * (via cwd) and want an answer about *that* directory, so they have to go.\n *\n * GIT_DIR is the worst offender: when it is set and GIT_WORK_TREE isn't, git\n * skips repository discovery entirely and \"tells Git that you are at the top\n * level of the working tree\", so `git rev-parse --show-toplevel` echoes back\n * the directory we asked about instead of the root containing it.\n *\n * https://github.com/altano/npm-packages/issues/299\n *\n * Variables that only tune discovery, and that a user has to opt into\n * deliberately (GIT_CEILING_DIRECTORIES, GIT_DISCOVERY_ACROSS_FILESYSTEM), are\n * intentionally left alone.\n */\nconst gitRepositoryVariables = [\n \"GIT_DIR\",\n \"GIT_WORK_TREE\",\n \"GIT_COMMON_DIR\",\n \"GIT_INDEX_FILE\",\n \"GIT_INDEX_VERSION\",\n \"GIT_OBJECT_DIRECTORY\",\n \"GIT_ALTERNATE_OBJECT_DIRECTORIES\",\n \"GIT_NAMESPACE\",\n \"GIT_PREFIX\",\n \"GIT_QUARANTINE_PATH\",\n] as const;\n\n/**\n * Inherited environment variables to drop, per command. The other version\n * control systems have no equivalent of GIT_DIR: they're told which repository\n * to use with a flag, never with the environment.\n */\nconst removedEnvironment = {\n git: gitRepositoryVariables,\n hg: [],\n sl: [],\n svn: [],\n svnadmin: [],\n svnrdump: [],\n} as const satisfies Record<RepositoryCommand, readonly string[]>;\n\nfunction getEnvironment(command: RepositoryCommand): NodeJS.ProcessEnv {\n const result: NodeJS.ProcessEnv = {\n ...process.env,\n ...environment[command],\n };\n for (const variable of removedEnvironment[command]) {\n delete result[variable];\n }\n return result;\n}\n\nexport async function repositoryExec(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): Promise<string> {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n return execFileAsync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: getEnvironment(command),\n }).then(({ stdout, stderr }) => {\n // console.timeEnd(msg);\n return stderr ? Promise.reject(new Error(stderr.trim())) : stdout.trim();\n });\n}\n\nexport function repositoryExecSync(\n cwd: string,\n command: RepositoryCommand,\n args: readonly string[],\n): string {\n // const msg = `Executing command: ${command} ${args.join(\" \")}`;\n // console.time(msg);\n const result = execFileSync(command, args, {\n cwd: cwd,\n encoding: \"utf8\",\n env: getEnvironment(command),\n }).trim();\n // console.timeEnd(msg);\n return result;\n}\n\nexport const createExecForDirectory = (\n cwd: string,\n): ((command: RepositoryCommand, args: readonly string[]) => Promise<string>) =>\n repositoryExec.bind(null, cwd);\n\n// Not being used.\n// export const createExecSyncForDirectory = (\n// cwd: string,\n// ): ((command: RepositoryCommand, args: readonly string[]) => string) =>\n// repositoryExecSync.bind(null, cwd);\n"],"mappings":";;;AAKA,MAAM,cAAc;CAClB,KAAK;EAEH,qBAAqB;EAErB,mBAAmB;EACnB,mBAAmB;EAEnB,oBAAoB;EACpB,qBAAqB;EACrB,iBAAiB;EACjB,kBAAkB;CACpB;CACA,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;CACT;CACA,IAAI;EAEF,UAAU;EAEV,QAAQ;EACR,OAAO;CACT;CACA,KAAK,CAAC;CACN,UAAU,CAAC;CACX,UAAU,CAAC;AACb;;;;;;AAuCA,MAAM,qBAAqB;CACzB,KAAK;EAlBL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAS0B;CAC1B,IAAI,CAAC;CACL,IAAI,CAAC;CACL,KAAK,CAAC;CACN,UAAU,CAAC;CACX,UAAU,CAAC;AACb;AAEA,SAAS,eAAe,SAA+C;CACrE,MAAM,SAA4B;EAChC,GAAG,QAAQ;EACX,GAAG,YAAY;CACjB;CACA,KAAK,MAAM,YAAY,mBAAmB,UACxC,OAAO,OAAO;CAEhB,OAAO;AACT;AAEA,eAAsB,eACpB,KACA,SACA,MACiB;CAGjB,OAAO,cAAc,SAAS,MAAM;EAC7B;EACL,UAAU;EACV,KAAK,eAAe,OAAO;CAC7B,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,aAAa;EAE9B,OAAO,SAAS,QAAQ,OAAO,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC,IAAI,OAAO,KAAK;CACzE,CAAC;AACH;AAEA,SAAgB,mBACd,KACA,SACA,MACQ;CASR,OANe,aAAa,SAAS,MAAM;EACpC;EACL,UAAU;EACV,KAAK,eAAe,OAAO;CAC7B,CAAC,CAAC,CAAC,KAES;AACd;AAEA,MAAa,0BACX,QAEA,eAAe,KAAK,MAAM,GAAG"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export const repositoryTypes = [\n \"git\",\n \"mercurial\",\n \"sapling\",\n \"subversion\",\n] as const;\n\nexport type RepositoryType = (typeof repositoryTypes)[number];\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["export const repositoryTypes = [\n \"git\",\n \"mercurial\",\n \"sapling\",\n \"subversion\",\n] as const;\n\nexport type RepositoryType = (typeof repositoryTypes)[number];\n"],"mappings":";AAAA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altano/repository-tools",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Misc tools for dealing with repositories of multiple version control systems (git, svn, etc)",
5
5
  "keywords": [
6
6
  "repository",
@@ -18,7 +18,7 @@
18
18
  "license": "ISC",
19
19
  "author": {
20
20
  "name": "Alan Norbauer",
21
- "email": "altano@gmail.com",
21
+ "email": "alan@norbauer.com",
22
22
  "url": "https://alan.norbauer.com"
23
23
  },
24
24
  "sideEffects": false,
@@ -36,38 +36,38 @@
36
36
  "dist/**/*.d.ts"
37
37
  ],
38
38
  "devDependencies": {
39
- "@arethetypeswrong/cli": "^0.18.2",
40
- "@types/node": "^25.5.0",
41
- "@vitest/coverage-v8": "^4.1.0",
42
- "@vitest/expect": "^4.1.0",
39
+ "@arethetypeswrong/cli": "^0.18.5",
40
+ "@types/node": "^26.1.1",
41
+ "@vitest/coverage-v8": "^4.1.10",
42
+ "@vitest/expect": "^4.1.10",
43
43
  "depcheck": "^1.4.7",
44
- "eslint": "^9.39.4",
45
- "find-cache-dir": "^5.0.0",
44
+ "eslint": "^9.39.5",
45
+ "find-cache-directory": "^6.0.0",
46
46
  "memize": "^2.1.1",
47
- "prettier": "^3.8.1",
47
+ "prettier": "3.9.6",
48
48
  "ts-assert-unreachable": "^0.0.9",
49
- "tsdown": "^0.21.4",
50
- "typescript": "^5.9.3",
51
- "vite": "^7.3.1",
52
- "vitest": "^4.1.0",
49
+ "tsdown": "^0.22.14",
50
+ "typescript": "^6.0.3",
51
+ "vite": "^8.1.5",
52
+ "vitest": "^4.1.10",
53
53
  "@altano/build-config": "0.0.1",
54
+ "@altano/disposable-directory": "0.0.3",
54
55
  "@altano/testing": "0.0.1",
55
- "@altano/tsconfig": "0.0.1",
56
- "@altano/disposable-directory": "0.0.2"
56
+ "@altano/tsconfig": "0.0.1"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
61
  "scripts": {
62
- "build": "tsdown --config-loader unrun --config ../build-config/tsdown.config.node.ts",
62
+ "build": "tsdown",
63
63
  "check:exports": "attw --pack . --profile esm-only --quiet",
64
64
  "check:types:src": "tsc --noEmit",
65
65
  "check:types:test": "tsc --noEmit --project ./tests/tsconfig.json",
66
66
  "check:unused-dependencies": "depcheck",
67
67
  "clean": "rm -rf .turbo && rm -rf .tsbuildinfo && rm -rf node_modules && rm -rf dist",
68
68
  "dev": "pnpm run build --watch",
69
- "format": "prettier --check src",
70
- "format:fix": "prettier --write src",
69
+ "format": "prettier --check .",
70
+ "format:fix": "prettier --write .",
71
71
  "lint": "eslint",
72
72
  "lint:fix": "TIMING=1 pnpm lint --fix",
73
73
  "lint:timing": "TIMING=1 pnpm lint",