Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
Upgrading version
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarcosp committed Nov 27, 2020
1 parent 638f8f5 commit be60c2a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "findr",
"version": "0.0.6",
"version": "0.0.7",
"description": "Findr CLI ● A simple and beatiful find & replace command-line interface.",
"license": "MIT",
"esy": {
Expand Down
90 changes: 90 additions & 0 deletions scripts/release-postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

const path = require("path");
const cp = require("child_process");
const fs = require("fs");

const platform = process.platform;

const binariesToCopy = ["styled-ppx"];

function find_arch() {
// The running binary is 64-bit, so the OS is clearly 64-bit.
if (process.arch === "x64") {
return "x64";
}

// All recent versions of Mac OS are 64-bit.
if (process.platform === "darwin") {
return "x64";
}

// 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 = !!(
rocess.env.SYSTEMROOT && fs.statSync(process.env.SYSTEMROOT)
);
} catch (err) {}

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

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

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

if (process.platform === "linux") {
const output = cp.execSync("getconf LONG_BIT", { encoding: "utf8" });
return output === "64\n" ? "x64" : "x86";
}

return "x86";
}

// Implementing it b/c we don"t want to depend on fs.copyFileSync which appears only in [email protected]
function copyFileSync(sourcePath, destPath) {
const data = fs.readFileSync(sourcePath);
const stat = fs.statSync(sourcePath);
fs.writeFileSync(destPath, data);
fs.chmodSync(destPath, stat.mode);
}

const copyPlatformBinaries = (platformPath) => {
const platformBuildPath = path.join(__dirname, platformPath);

binariesToCopy.forEach((binaryPath) => {
const sourcePath = path.join(platformBuildPath, binaryPath);
const destPath = path.join(__dirname, binaryPath);
if (fs.existsSync(destPath)) {
fs.unlinkSync(destPath);
}
copyFileSync(sourcePath, destPath);
fs.chmodSync(destPath, 0o755);
});
};

const arch = find_arch();
const platformPath = "platform-" + platform + "-" + arch;
const supported = fs.existsSync(platformPath);

if (!supported) {
console.error("styled-ppx does not support this platform :(");
console.error("");
console.error("If you want styled-ppx to support this platform natively,");
console.error(
"please open an issue here: https://github.com/davesnx/styled-ppx/issues/new"
);
console.error("Specify that you are on the " + platform + " platform,");
console.error("and on the " + arch + " architecture.");
process.exit(1);
}

copyPlatformBinaries(platformPath);p

0 comments on commit be60c2a

Please sign in to comment.