workspace-tools 0.40.4 → 0.41.1

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.
Files changed (186) hide show
  1. package/README.md +39 -1
  2. package/lib/dependencies/index.d.ts +2 -2
  3. package/lib/dependencies/index.js +31 -12
  4. package/lib/dependencies/index.js.map +1 -1
  5. package/lib/dependencies/transitiveDeps.d.ts +1 -1
  6. package/lib/dependencies/transitiveDeps.js +59 -38
  7. package/lib/dependencies/transitiveDeps.js.map +1 -1
  8. package/lib/getPackageInfo.d.ts +7 -5
  9. package/lib/getPackageInfo.js +46 -39
  10. package/lib/getPackageInfo.js.map +1 -1
  11. package/lib/getPackageInfos.d.ts +31 -8
  12. package/lib/getPackageInfos.js +41 -41
  13. package/lib/getPackageInfos.js.map +1 -1
  14. package/lib/git/config.d.ts +1 -1
  15. package/lib/git/config.js +15 -12
  16. package/lib/git/config.js.map +1 -1
  17. package/lib/git/getDefaultRemote.js +45 -30
  18. package/lib/git/getDefaultRemote.js.map +1 -1
  19. package/lib/git/getDefaultRemoteBranch.d.ts +1 -1
  20. package/lib/git/getDefaultRemoteBranch.js +35 -24
  21. package/lib/git/getDefaultRemoteBranch.js.map +1 -1
  22. package/lib/git/getRepositoryName.d.ts +1 -1
  23. package/lib/git/getRepositoryName.js +17 -19
  24. package/lib/git/getRepositoryName.js.map +1 -1
  25. package/lib/git/git.d.ts +2 -5
  26. package/lib/git/git.js +62 -64
  27. package/lib/git/git.js.map +1 -1
  28. package/lib/git/gitUtilities.d.ts +3 -3
  29. package/lib/git/gitUtilities.js +377 -147
  30. package/lib/git/gitUtilities.js.map +1 -1
  31. package/lib/git/index.d.ts +5 -5
  32. package/lib/git/index.js +50 -28
  33. package/lib/git/index.js.map +1 -1
  34. package/lib/git/types.js +4 -3
  35. package/lib/git/types.js.map +1 -1
  36. package/lib/graph/createDependencyMap.d.ts +12 -2
  37. package/lib/graph/createDependencyMap.js +18 -10
  38. package/lib/graph/createDependencyMap.js.map +1 -1
  39. package/lib/graph/createPackageGraph.d.ts +10 -6
  40. package/lib/graph/createPackageGraph.js +58 -42
  41. package/lib/graph/createPackageGraph.js.map +1 -1
  42. package/lib/graph/getPackageDependencies.d.ts +2 -2
  43. package/lib/graph/getPackageDependencies.js +24 -53
  44. package/lib/graph/getPackageDependencies.js.map +1 -1
  45. package/lib/graph/index.d.ts +4 -4
  46. package/lib/graph/index.js +25 -27
  47. package/lib/graph/index.js.map +1 -1
  48. package/lib/index.d.ts +29 -27
  49. package/lib/index.js +154 -75
  50. package/lib/index.js.map +1 -1
  51. package/lib/isCachingEnabled.js +17 -6
  52. package/lib/isCachingEnabled.js.map +1 -1
  53. package/lib/lockfile/nameAtVersion.js +9 -4
  54. package/lib/lockfile/nameAtVersion.js.map +1 -1
  55. package/lib/lockfile/parseBerryLock.d.ts +1 -1
  56. package/lib/lockfile/parseBerryLock.js +13 -11
  57. package/lib/lockfile/parseBerryLock.js.map +1 -1
  58. package/lib/lockfile/parseLockFile.d.ts +2 -0
  59. package/lib/lockfile/parseLockFile.js +87 -0
  60. package/lib/lockfile/parseLockFile.js.map +1 -0
  61. package/lib/lockfile/parseNpmLock.d.ts +1 -1
  62. package/lib/lockfile/parseNpmLock.js +15 -7
  63. package/lib/lockfile/parseNpmLock.js.map +1 -1
  64. package/lib/lockfile/parsePnpmLock.d.ts +1 -1
  65. package/lib/lockfile/parsePnpmLock.js +14 -9
  66. package/lib/lockfile/parsePnpmLock.js.map +1 -1
  67. package/lib/lockfile/queryLockFile.d.ts +1 -1
  68. package/lib/lockfile/queryLockFile.js +11 -6
  69. package/lib/lockfile/queryLockFile.js.map +1 -1
  70. package/lib/lockfile/readYaml.js +17 -9
  71. package/lib/lockfile/readYaml.js.map +1 -1
  72. package/lib/lockfile/types.js +3 -2
  73. package/lib/lockfile/types.js.map +1 -1
  74. package/lib/logging.js +10 -6
  75. package/lib/logging.js.map +1 -1
  76. package/lib/paths.d.ts +4 -1
  77. package/lib/paths.js +60 -58
  78. package/lib/paths.js.map +1 -1
  79. package/lib/scope.js +30 -21
  80. package/lib/scope.js.map +1 -1
  81. package/lib/types/Catalogs.js +8 -3
  82. package/lib/types/Catalogs.js.map +1 -1
  83. package/lib/types/PackageGraph.d.ts +5 -1
  84. package/lib/types/PackageGraph.js +4 -3
  85. package/lib/types/PackageGraph.js.map +1 -1
  86. package/lib/types/PackageInfo.d.ts +1 -1
  87. package/lib/types/PackageInfo.js +3 -2
  88. package/lib/types/PackageInfo.js.map +1 -1
  89. package/lib/types/WorkspaceInfo.d.ts +3 -5
  90. package/lib/types/WorkspaceInfo.js +3 -2
  91. package/lib/types/WorkspaceInfo.js.map +1 -1
  92. package/lib/types/WorkspaceManager.js +4 -0
  93. package/lib/types/WorkspaceManager.js.map +1 -0
  94. package/lib/workspaces/catalogsToYaml.d.ts +1 -1
  95. package/lib/workspaces/catalogsToYaml.js +12 -10
  96. package/lib/workspaces/catalogsToYaml.js.map +1 -1
  97. package/lib/workspaces/findWorkspacePath.d.ts +2 -1
  98. package/lib/workspaces/findWorkspacePath.js +10 -12
  99. package/lib/workspaces/findWorkspacePath.js.map +1 -1
  100. package/lib/workspaces/getAllPackageJsonFiles.d.ts +10 -4
  101. package/lib/workspaces/getAllPackageJsonFiles.js +32 -22
  102. package/lib/workspaces/getAllPackageJsonFiles.js.map +1 -1
  103. package/lib/workspaces/getCatalogVersion.d.ts +1 -1
  104. package/lib/workspaces/getCatalogVersion.js +19 -32
  105. package/lib/workspaces/getCatalogVersion.js.map +1 -1
  106. package/lib/workspaces/getCatalogs.d.ts +8 -2
  107. package/lib/workspaces/getCatalogs.js +23 -15
  108. package/lib/workspaces/getCatalogs.js.map +1 -1
  109. package/lib/workspaces/getChangedPackages.d.ts +1 -1
  110. package/lib/workspaces/getChangedPackages.js +47 -30
  111. package/lib/workspaces/getChangedPackages.js.map +1 -1
  112. package/lib/workspaces/getPackagesByFiles.js +29 -24
  113. package/lib/workspaces/getPackagesByFiles.js.map +1 -1
  114. package/lib/workspaces/getWorkspaceInfos.d.ts +36 -0
  115. package/lib/workspaces/getWorkspaceInfos.js +60 -0
  116. package/lib/workspaces/getWorkspaceInfos.js.map +1 -0
  117. package/lib/workspaces/getWorkspaceManagerRoot.d.ts +16 -0
  118. package/lib/workspaces/getWorkspaceManagerRoot.js +32 -0
  119. package/lib/workspaces/getWorkspaceManagerRoot.js.map +1 -0
  120. package/lib/workspaces/getWorkspacePackagePaths.d.ts +17 -2
  121. package/lib/workspaces/getWorkspacePackagePaths.js +138 -24
  122. package/lib/workspaces/getWorkspacePackagePaths.js.map +1 -1
  123. package/lib/workspaces/getWorkspacePatterns.d.ts +11 -0
  124. package/lib/workspaces/getWorkspacePatterns.js +25 -0
  125. package/lib/workspaces/getWorkspacePatterns.js.map +1 -0
  126. package/lib/workspaces/implementations/WorkspaceUtilities.d.ts +27 -0
  127. package/lib/workspaces/implementations/WorkspaceUtilities.js +4 -0
  128. package/lib/workspaces/implementations/WorkspaceUtilities.js.map +1 -0
  129. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.d.ts +9 -0
  130. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js +38 -0
  131. package/lib/workspaces/implementations/getPackageJsonWorkspacePatterns.js.map +1 -0
  132. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.d.ts +19 -5
  133. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js +38 -40
  134. package/lib/workspaces/implementations/getWorkspaceManagerAndRoot.js.map +1 -1
  135. package/lib/workspaces/implementations/getWorkspaceUtilities.d.ts +4 -36
  136. package/lib/workspaces/implementations/getWorkspaceUtilities.js +35 -20
  137. package/lib/workspaces/implementations/getWorkspaceUtilities.js.map +1 -1
  138. package/lib/workspaces/implementations/index.d.ts +2 -2
  139. package/lib/workspaces/implementations/index.js +19 -7
  140. package/lib/workspaces/implementations/index.js.map +1 -1
  141. package/lib/workspaces/implementations/lerna.d.ts +2 -20
  142. package/lib/workspaces/implementations/lerna.js +77 -62
  143. package/lib/workspaces/implementations/lerna.js.map +1 -1
  144. package/lib/workspaces/implementations/npm.d.ts +3 -17
  145. package/lib/workspaces/implementations/npm.js +12 -43
  146. package/lib/workspaces/implementations/npm.js.map +1 -1
  147. package/lib/workspaces/implementations/pnpm.d.ts +2 -30
  148. package/lib/workspaces/implementations/pnpm.js +32 -89
  149. package/lib/workspaces/implementations/pnpm.js.map +1 -1
  150. package/lib/workspaces/implementations/rush.d.ts +2 -22
  151. package/lib/workspaces/implementations/rush.js +26 -69
  152. package/lib/workspaces/implementations/rush.js.map +1 -1
  153. package/lib/workspaces/implementations/yarn.d.ts +2 -35
  154. package/lib/workspaces/implementations/yarn.js +33 -85
  155. package/lib/workspaces/implementations/yarn.js.map +1 -1
  156. package/lib/workspaces/wrapWorkspaceUtility.d.ts +31 -0
  157. package/lib/workspaces/wrapWorkspaceUtility.js +47 -0
  158. package/lib/workspaces/wrapWorkspaceUtility.js.map +1 -0
  159. package/package.json +21 -12
  160. package/lib/getPackagePaths.d.ts +0 -10
  161. package/lib/getPackagePaths.js +0 -49
  162. package/lib/getPackagePaths.js.map +0 -1
  163. package/lib/infoFromPackageJson.d.ts +0 -17
  164. package/lib/infoFromPackageJson.js +0 -11
  165. package/lib/infoFromPackageJson.js.map +0 -1
  166. package/lib/lockfile/index.d.ts +0 -6
  167. package/lib/lockfile/index.js +0 -105
  168. package/lib/lockfile/index.js.map +0 -1
  169. package/lib/workspaces/WorkspaceManager.js +0 -3
  170. package/lib/workspaces/WorkspaceManager.js.map +0 -1
  171. package/lib/workspaces/getWorkspacePackageInfo.d.ts +0 -26
  172. package/lib/workspaces/getWorkspacePackageInfo.js +0 -76
  173. package/lib/workspaces/getWorkspacePackageInfo.js.map +0 -1
  174. package/lib/workspaces/getWorkspaceRoot.d.ts +0 -25
  175. package/lib/workspaces/getWorkspaceRoot.js +0 -35
  176. package/lib/workspaces/getWorkspaceRoot.js.map +0 -1
  177. package/lib/workspaces/getWorkspaces.d.ts +0 -20
  178. package/lib/workspaces/getWorkspaces.js +0 -39
  179. package/lib/workspaces/getWorkspaces.js.map +0 -1
  180. package/lib/workspaces/implementations/packageJsonWorkspaces.d.ts +0 -31
  181. package/lib/workspaces/implementations/packageJsonWorkspaces.js +0 -104
  182. package/lib/workspaces/implementations/packageJsonWorkspaces.js.map +0 -1
  183. package/lib/workspaces/listOfWorkspacePackageNames.d.ts +0 -5
  184. package/lib/workspaces/listOfWorkspacePackageNames.js +0 -11
  185. package/lib/workspaces/listOfWorkspacePackageNames.js.map +0 -1
  186. /package/lib/{workspaces → types}/WorkspaceManager.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git/git.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,qBAAqB;AACrB,EAAE;;;AAEF,iDAA8E;AAU9E,MAAa,QAAS,SAAQ,KAAK;IAIjC,YAAY,OAAe,EAAE,aAAuB,EAAE,SAA4B;QAChF,IAAI,aAAa,YAAY,KAAK,EAAE;YAClC,KAAK,CAAC,GAAG,OAAO,KAAK,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;SAC/C;aAAM,IAAI,SAAS,EAAE,MAAM,EAAE;YAC5B,KAAK,CAAC,GAAG,OAAO,gBAAgB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;SACrD;aAAM;YACL,KAAK,CAAC,OAAO,CAAC,CAAC;SAChB;QACD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAfD,4BAeC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/G,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SA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,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;KAC5G;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA/CD,kBA+CC;AAED;;;;;;GAMG;AACH,SAAgB,WAAW,CAAC,IAAc,EAAE,OAAqD;IAC/F,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACrC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;QACtB,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE;YACxB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;SACtB;QAED,MAAM,IAAI,QAAQ,CAAC,4CAA4C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;MAC3E,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE;MACtC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KAC7C;AACH,CAAC;AAXD,kCAWC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,MAAwB,EAAE,OAA0C;IACnG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,kGAAkG;QAClG,OAAO,EAAE,CAAC;KACX;IAED,OAAO,MAAM,CAAC,MAAM;SACjB,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,kBAAkB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC;AAVD,4CAUC"}
1
+ {"version":3,"sources":["../../src/git/git.ts"],"sourcesContent":["//\n// Basic git wrappers\n//\n\nimport { spawnSync, type SpawnSyncOptions, type SpawnSyncReturns } from \"child_process\";\nimport { type GitCommonOptions } from \"./types.js\";\n\nexport type GitOptions = Omit<SpawnSyncOptions, \"cwd\"> &\n GitCommonOptions & {\n /** Operation description to be used in error message (formatted as start of sentence) */\n description?: string;\n debug?: boolean;\n };\n\nexport class GitError extends Error {\n public readonly originalError: unknown;\n public readonly gitOutput?: GitProcessOutput;\n\n constructor(message: string, originalError?: unknown, gitOutput?: GitProcessOutput) {\n if (originalError instanceof Error) {\n super(`${message}: ${originalError.message}`);\n } else if (gitOutput?.stderr) {\n super(`${message} -- stderr:\\n${gitOutput.stderr}`);\n } else {\n super(message);\n }\n this.originalError = originalError;\n this.gitOutput = gitOutput;\n }\n}\n\n/**\n * A global maxBuffer override for all git operations.\n * Bumps up the default to 500MB instead of 1MB.\n * Override this value with the `GIT_MAX_BUFFER` environment variable.\n */\nconst defaultMaxBuffer = process.env.GIT_MAX_BUFFER ? parseInt(process.env.GIT_MAX_BUFFER) : 500 * 1024 * 1024;\n\nconst isDebug = !!process.env.GIT_DEBUG;\n\nexport type GitProcessOutput = {\n stderr: string;\n stdout: string;\n success: boolean;\n} & Omit<SpawnSyncReturns<string | Buffer>, \"stdout\" | \"stderr\">;\n\n/** Observes the git operations called from `git()` or `gitFailFast()` */\nexport type GitObserver = (args: string[], output: GitProcessOutput) => void;\nconst observers: GitObserver[] = [];\nlet observing: boolean;\n\n/**\n * Adds an observer for the git operations, e.g. for testing\n * @returns a function to remove the observer\n */\nexport function addGitObserver(observer: GitObserver): () => void {\n observers.push(observer);\n return () => removeGitObserver(observer);\n}\n\n/** Clear all git observers */\nexport function clearGitObservers(): void {\n observers.splice(0, observers.length);\n}\n\n/** Remove a git observer */\nfunction removeGitObserver(observer: GitObserver): void {\n const index = observers.indexOf(observer);\n if (index > -1) {\n observers.splice(index, 1);\n }\n}\n\n/**\n * Runs git command - use this for read-only commands, or if you'd like to explicitly check the\n * result and implement custom error handling.\n *\n * The caller is responsible for validating the input.\n * `shell` will always be set to false.\n */\nexport function git(args: string[], options?: GitOptions): GitProcessOutput {\n if (args.some((arg) => arg.startsWith(\"--upload-pack\"))) {\n // This is a security issue and not needed for any expected usage of this library.\n throw new GitError(\"git command contains --upload-pack, which is not allowed: \" + args.join(\" \"));\n }\n\n const gitDescription = `git ${args.join(\" \")}`;\n const { throwOnError, description = gitDescription, debug = isDebug, ...spawnOptions } = options || {};\n\n debug && console.log(gitDescription);\n\n let results: SpawnSyncReturns<string | Buffer>;\n try {\n // this only throws if git isn't found or other rare cases\n results = spawnSync(\"git\", args, { maxBuffer: defaultMaxBuffer, ...spawnOptions });\n } catch (e) {\n throw new GitError(`${description} failed (while spawning process)`, e);\n }\n\n const output: GitProcessOutput = {\n ...results,\n // these may be undefined if stdio: inherit is set\n stderr: (results.stderr || \"\").toString().trimEnd(),\n stdout: (results.stdout || \"\").toString().trimEnd(),\n success: results.status === 0,\n };\n\n if (debug) {\n console.log(\"exited with code \" + results.status);\n output.stdout && console.log(\"git stdout:\\n\", output.stdout);\n output.stderr && console.warn(\"git stderr:\\n\", output.stderr);\n }\n\n // notify observers, flipping the observing bit to prevent infinite loops\n if (!observing) {\n observing = true;\n for (const observer of observers) {\n observer(args, output);\n }\n observing = false;\n }\n\n if (!output.success && throwOnError) {\n throw new GitError(`${description} failed${output.stderr ? `\\n${output.stderr}` : \"\"}`, undefined, output);\n }\n\n return output;\n}\n\n/**\n * Run a git command. Use this for commands that make critical changes to the filesystem.\n * If it fails, throw an error and set `process.exitCode = 1` (unless `options.noExitCode` is set).\n *\n * The caller is responsible for validating the input.\n * `shell` will always be set to false.\n */\nexport function gitFailFast(args: string[], options?: GitCommonOptions & { noExitCode?: boolean }): void {\n const gitResult = git(args, options);\n if (!gitResult.success) {\n if (!options?.noExitCode) {\n process.exitCode = 1;\n }\n\n throw new GitError(`CRITICAL ERROR: running git command: git ${args.join(\" \")}!\n ${gitResult.stdout?.toString().trimEnd()}\n ${gitResult.stderr?.toString().trimEnd()}`);\n }\n}\n\n/**\n * Processes git command output by splitting it into lines and filtering out empty lines.\n * Also filters out `node_modules` lines if specified in options.\n *\n * If the command failed with stderr output, an error is thrown.\n *\n * @param output - The git command output to process\n * @returns An array of lines (presumably file paths), or an empty array if the command failed\n * without stderr output.\n * @internal\n */\nexport function processGitOutput(output: GitProcessOutput, options?: { excludeNodeModules?: boolean }): string[] {\n if (!output.success) {\n // If the intent was to throw on failure, `throwOnError` should have been set for the git command.\n return [];\n }\n\n return output.stdout\n .split(/\\n/)\n .map((line) => line.trim())\n .filter((line) => !!line && (!options?.excludeNodeModules || !line.includes(\"node_modules\")));\n}\n"],"names":["GitError","addGitObserver","clearGitObservers","git","gitFailFast","processGitOutput","Error","message","originalError","gitOutput","stderr","defaultMaxBuffer","process","env","GIT_MAX_BUFFER","parseInt","isDebug","GIT_DEBUG","observers","observing","observer","push","removeGitObserver","splice","length","index","indexOf","args","options","some","arg","startsWith","join","gitDescription","throwOnError","description","debug","spawnOptions","console","log","results","spawnSync","maxBuffer","e","output","toString","trimEnd","stdout","success","status","warn","undefined","gitResult","noExitCode","exitCode","split","map","line","trim","filter","excludeNodeModules","includes"],"mappings":"AAAA,EAAE;AACF,qBAAqB;AACrB,EAAE;;;;;;;;;;;;QAYWA;eAAAA;;QAyCGC;eAAAA;;QAMAC;eAAAA;;QAmBAC;eAAAA;;QAwDAC;eAAAA;;QAwBAC;eAAAA;;;+BA5JwD;;;;;;;;;;;;;;AAUjE,MAAML,iBAAiBM;IAI5B,YAAYC,OAAe,EAAEC,aAAuB,EAAEC,SAA4B,CAAE;QAClF,IAAID,yBAAyBF,OAAO;YAClC,KAAK,CAAC,GAAGC,QAAQ,EAAE,EAAEC,cAAcD,OAAO,EAAE,GALhD,uBAAgBC,iBAAhB,KAAA,IACA,uBAAgBC,aAAhB,KAAA;QAKE,OAAO,IAAIA,WAAWC,QAAQ;YAC5B,KAAK,CAAC,GAAGH,QAAQ,aAAa,EAAEE,UAAUC,MAAM,EAAE,GAPtD,uBAAgBF,iBAAhB,KAAA,IACA,uBAAgBC,aAAhB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zC,EAAEM,UAAU1C,MAAM,EAAEmC,WAAWC,WAAW;IAC5C;AACF;AAaO,SAASzC,iBAAiBuC,MAAwB,EAAEhB,OAA0C;IACnG,IAAI,CAACgB,OAAOI,OAAO,EAAE;QACnB,kGAAkG;QAClG,OAAO,EAAE;IACX;IAEA,OAAOJ,OAAOG,MAAM,CACjBQ,KAAK,CAAC,MACNC,GAAG,CAAC,CAACC,OAASA,KAAKC,IAAI,IACvBC,MAAM,CAAC,CAACF,OAAS,CAAC,CAACA,QAAS,CAAA,CAAC7B,SAASgC,sBAAsB,CAACH,KAAKI,QAAQ,CAAC,eAAc;AAC9F"}
@@ -1,4 +1,4 @@
1
- import type { GetChangesBetweenRefsOptions, GitBranchOptions, GitCommitOptions, GitCommonOptions, GitFetchOptions, GitInitOptions, GitStageOptions, ParsedRemoteBranch, ParseRemoteBranchOptions } from "./types";
1
+ import type { GetChangesBetweenRefsOptions, GitBranchOptions, GitCommitOptions, GitCommonOptions, GitFetchOptions, GitInitOptions, GitStageOptions, ParsedRemoteBranch, ParseRemoteBranchOptions } from "./types.js";
2
2
  /**
3
3
  * Get a list of files with untracked changes.
4
4
  * Throws an error on failure by default.
@@ -86,9 +86,9 @@ export declare function getUserEmail(cwd: string): string | null;
86
86
  *
87
87
  * @returns The branch name if successful, null otherwise
88
88
  */
89
- export declare function getBranchName(options: GitCommonOptions): string;
89
+ export declare function getBranchName(options: GitCommonOptions): string | null;
90
90
  /** @deprecated Use object params version */
91
- export declare function getBranchName(cwd: string): string;
91
+ export declare function getBranchName(cwd: string): string | null;
92
92
  /**
93
93
  * Gets the full reference path for a given branch.
94
94
  * `branch` here is the short branch name, e.g. `branch-name`.