@sanity/pkg-utils 7.0.4 → 7.1.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.
package/dist/index.js CHANGED
@@ -33,10 +33,10 @@ import esbuild$1 from "esbuild";
33
33
  import treeify from "treeify";
34
34
  import prettyBytes from "pretty-bytes";
35
35
  import prompts from "prompts";
36
+ import { execSync } from "node:child_process";
36
37
  import getLatestVersion from "get-latest-version";
37
38
  import gitUrlParse from "git-url-parse";
38
39
  import { outdent } from "outdent";
39
- import parseGitConfig from "parse-git-config";
40
40
  import { scan, startWith, distinctUntilChanged } from "rxjs/operators";
41
41
  import globby from "globby";
42
42
  import chokidar from "chokidar";
@@ -1019,7 +1019,6 @@ async function doExtract(ctx, task) {
1019
1019
  ), targetPaths = entry.targetPaths.map((targetPath) => path.resolve(cwd, targetPath)), filePaths = targetPaths.map((targetPath) => path.relative(outDir, targetPath)), result = await extractTypes({
1020
1020
  bundledPackages: bundledPackages || [],
1021
1021
  customTags: config2?.extract?.customTags,
1022
- cwd,
1023
1022
  distPath: outDir,
1024
1023
  exportPath,
1025
1024
  files,
@@ -1625,7 +1624,7 @@ const overridableDefaults = {
1625
1624
  }
1626
1625
  ]
1627
1626
  }, RE_NAME = /^(?:@(?:[a-z0-9-*~][a-z0-9-*._~]*)\/)?[a-z0-9-~][a-z0-9-._~]*$/i, defaultTemplate = async ({ cwd, logger, packagePath }) => {
1628
- const gitConfig = await parseGitConfig({ cwd, type: "global" });
1627
+ const gitConfig = getGitUserConfig(cwd);
1629
1628
  return {
1630
1629
  options: [
1631
1630
  {
@@ -1670,13 +1669,13 @@ const overridableDefaults = {
1670
1669
  name: "authorName",
1671
1670
  type: "string",
1672
1671
  description: "package author name",
1673
- initial: gitConfig?.user?.name
1672
+ initial: gitConfig.user
1674
1673
  },
1675
1674
  {
1676
1675
  name: "authorEmail",
1677
1676
  type: "string",
1678
1677
  description: "package author email",
1679
- initial: gitConfig?.user?.email
1678
+ initial: gitConfig.email
1680
1679
  },
1681
1680
  {
1682
1681
  name: "license",
@@ -2027,6 +2026,14 @@ async function resolveLatestDeps(deps) {
2027
2026
  }
2028
2027
  return latestDeps;
2029
2028
  }
2029
+ function getGitUserConfig(cwd) {
2030
+ let user, email;
2031
+ try {
2032
+ user = execSync("git config user.name", { encoding: "utf8", cwd }).trim() || void 0, email = execSync("git config user.email", { encoding: "utf8", cwd }).trim() || void 0;
2033
+ } catch {
2034
+ }
2035
+ return { user, email };
2036
+ }
2030
2037
  async function init(options) {
2031
2038
  if (!options.cwd)
2032
2039
  throw new Error("Missing required option: cwd");