Skip to content

Commit

Permalink
Merge pull request #27 from esy/prometheansacrifice/fix-postinstall
Browse files Browse the repository at this point in the history
Bug fixes in release-postinstall.js
  • Loading branch information
ManasJayanth authored Jul 19, 2024
2 parents d9cdad3 + cdb9c0f commit 910c445
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 92 deletions.
49 changes: 3 additions & 46 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,14 +111,10 @@ 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", [
copyPlatformBinaries("platform-esy-npm-release-win32-x64", [
"bin",
"_export",
]);
Expand Down
49 changes: 3 additions & 46 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,14 +111,10 @@ 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", [
copyPlatformBinaries("platform-esy-npm-release-win32-x64", [
"bin",
"_export",
]);
Expand Down

0 comments on commit 910c445

Please sign in to comment.