@zq-silk/yui 0.8.8 → 0.8.9
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.
|
@@ -79,10 +79,21 @@ export function createProductionRuntimeIdentityPorts(packageRoot, entryPath, env
|
|
|
79
79
|
}
|
|
80
80
|
function readGitHead(packageRoot) {
|
|
81
81
|
try {
|
|
82
|
-
const
|
|
83
|
-
|
|
82
|
+
const resolvedPackageRoot = realpathSync(packageRoot);
|
|
83
|
+
const rootResult = spawnSync("git", ["-C", resolvedPackageRoot, "rev-parse", "--show-toplevel"], { encoding: "utf8", timeout: 1_500, stdio: ["ignore", "pipe", "ignore"] });
|
|
84
|
+
if (rootResult.status !== 0)
|
|
84
85
|
return null;
|
|
85
|
-
const
|
|
86
|
+
const repositoryRoot = realpathSync(rootResult.stdout.trim());
|
|
87
|
+
// `git -C` searches parent directories. A globally installed package may
|
|
88
|
+
// therefore appear to belong to an unrelated repository that happens to
|
|
89
|
+
// contain the package manager directory (for example ~/.nvm). Only the
|
|
90
|
+
// package's own checkout is valid source identity evidence.
|
|
91
|
+
if (repositoryRoot !== resolvedPackageRoot)
|
|
92
|
+
return null;
|
|
93
|
+
const headResult = spawnSync("git", ["-C", resolvedPackageRoot, "rev-parse", "HEAD"], { encoding: "utf8", timeout: 1_500, stdio: ["ignore", "pipe", "ignore"] });
|
|
94
|
+
if (headResult.status !== 0)
|
|
95
|
+
return null;
|
|
96
|
+
const head = headResult.stdout.trim();
|
|
86
97
|
return /^[a-f0-9]{7,40}$/u.test(head) ? head : null;
|
|
87
98
|
}
|
|
88
99
|
catch {
|