Skip to content

Commit

Permalink
Bug fixes in release-postinstall.js
Browse files Browse the repository at this point in the history
1. Removes arch() detection on Windows
  • Loading branch information
ManasJayanth committed Jul 18, 2024
1 parent d9cdad3 commit a5cc412
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 90 deletions.
47 changes: 2 additions & 45 deletions dist/release-postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,6 @@ function copyRecursive(srcDir, dstDir) {
return results;
}

function arch() {
/**
* On Windows, the most reliable way to detect a 64-bit OS from within a 32-bit
* app is based on the presence of a WOW64 file: %SystemRoot%\SysNative.
* See: https://twitter.com/feross/status/776949077208510464
*/
if (process.platform === "win32") {
var useEnv = false;
try {
useEnv = !!(
process.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT)
);
} catch (err) {}

var sysRoot = useEnv ? process.env.SYSTEMROOT : "C:\\Windows";

// If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application.
var isWOW64 = false;
try {
isWOW64 = !!fs.statSync(path.join(sysRoot, "sysnative"));
} catch (err) {}

return isWOW64 ? "x64" : "x86";
}

/**
* On Linux, use the `getconf` command to get the architecture.
*/
if (process.platform === "linux") {
var output = cp.execSync("getconf LONG_BIT", { encoding: "utf8" });
return output === "64\n" ? "x64" : "x86";
}

/**
* If none of the above, assume the architecture is 32-bit.
*/
return process.arch;
}

// implementing it b/c we don't want to depend on fs.copyFileSync which appears
// only in [email protected]
function copyFileSync(sourcePath, destPath) {
Expand All @@ -105,7 +66,7 @@ function copyFileSync(sourcePath, destPath) {
var copyPlatformBinaries = (platformPath, foldersToCopy) => {
var platformBuildPath = path.join(__dirname, platformPath);

let foldersToCopy, binariesToCopy;
let binariesToCopy;

binariesToCopy = Object.keys(packageJson.bin).map(function (name) {
return packageJson.bin[name];
Expand Down Expand Up @@ -150,13 +111,9 @@ try {
console.log("Could not create _export folder");
}

const platformArch = arch();
const platformArch = process.arch;
switch (platform) {
case "win32":
if (platformArch !== "x64") {
console.warn("error: x86 is currently not supported on Windows");
process.exit(1);
}
copyPlatformBinaries("platform-esy-npm-release-windows-x64", [
"bin",
"_export",
Expand Down
47 changes: 2 additions & 45 deletions release-postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,45 +47,6 @@ function copyRecursive(srcDir, dstDir) {
return results;
}

function arch() {
/**
* On Windows, the most reliable way to detect a 64-bit OS from within a 32-bit
* app is based on the presence of a WOW64 file: %SystemRoot%\SysNative.
* See: https://twitter.com/feross/status/776949077208510464
*/
if (process.platform === "win32") {
var useEnv = false;
try {
useEnv = !!(
process.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT)
);
} catch (err) {}

var sysRoot = useEnv ? process.env.SYSTEMROOT : "C:\\Windows";

// If %SystemRoot%\SysNative exists, we are in a WOW64 FS Redirected application.
var isWOW64 = false;
try {
isWOW64 = !!fs.statSync(path.join(sysRoot, "sysnative"));
} catch (err) {}

return isWOW64 ? "x64" : "x86";
}

/**
* On Linux, use the `getconf` command to get the architecture.
*/
if (process.platform === "linux") {
var output = cp.execSync("getconf LONG_BIT", { encoding: "utf8" });
return output === "64\n" ? "x64" : "x86";
}

/**
* If none of the above, assume the architecture is 32-bit.
*/
return process.arch;
}

// implementing it b/c we don't want to depend on fs.copyFileSync which appears
// only in [email protected]
function copyFileSync(sourcePath, destPath) {
Expand All @@ -105,7 +66,7 @@ function copyFileSync(sourcePath, destPath) {
var copyPlatformBinaries = (platformPath, foldersToCopy) => {
var platformBuildPath = path.join(__dirname, platformPath);

let foldersToCopy, binariesToCopy;
let binariesToCopy;

binariesToCopy = Object.keys(packageJson.bin).map(function (name) {
return packageJson.bin[name];
Expand Down Expand Up @@ -150,13 +111,9 @@ try {
console.log("Could not create _export folder");
}

const platformArch = arch();
const platformArch = process.arch;
switch (platform) {
case "win32":
if (platformArch !== "x64") {
console.warn("error: x86 is currently not supported on Windows");
process.exit(1);
}
copyPlatformBinaries("platform-esy-npm-release-windows-x64", [
"bin",
"_export",
Expand Down

0 comments on commit a5cc412

Please sign in to comment.