Skip to content

Commit

Permalink
Merge pull request #21 from Schmavery/patch-1
Browse files Browse the repository at this point in the history
Copy bsb6 file in postinstall
  • Loading branch information
baransu authored Oct 8, 2019
2 parents 0590a64 + 516b1eb commit adbb935
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 30 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Second, add it to `ppx-flags` in your `bsconfig.json`:
"ppx-flags": ["@baransu/graphql_ppx_re/ppx"]
```

If you're using bs-platform 6.x, add this to `bsconfig.json` instead:
```json
"ppx-flags": ["@baransu/graphql_ppx_re/ppx6"]
```

## Native

If you want to use native version edit your `esy.json` file
Expand Down
65 changes: 35 additions & 30 deletions copyPlatformBinaryInPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,45 @@ if (platform === "win32") {
platform = "win";
}

var filename = "bin/graphql_ppx-" + platform + "-" + arch + ".exe";
var supported = fs.existsSync(filename);

if (!supported) {
console.error("graphql_ppx does not support this platform :(");
console.error("");
console.error("graphql_ppx comes prepacked as built binaries to avoid large");
console.error("dependencies at build-time.");
console.error("");
console.error("If you want graphql_ppx to support this platform natively,");
console.error("please open an issue at our repository, linked above. Please");
console.error("specify that you are on the " + platform + " platform,");
console.error("on the " + arch + " architecture.");

if (!process.env.IS_GRAPHQL_PPX_CI) {
process.exit(1);
copyBinary("bin/graphql_ppx-" + platform + "-" + arch + ".exe", "ppx");
copyBinary("bin/bsb6/graphql_ppx-" + platform + "-" + arch + ".exe", "ppx6");

function copyBinary(filename, destFilename) {
var supported = fs.existsSync(filename);

if (!supported) {
console.error("graphql_ppx does not support this platform :(");
console.error("");
console.error("graphql_ppx comes prepacked as built binaries to avoid large");
console.error("dependencies at build-time.");
console.error("");
console.error("If you want graphql_ppx to support this platform natively,");
console.error("please open an issue at our repository, linked above. Please");
console.error("specify that you are on the " + platform + " platform,");
console.error("on the " + arch + " architecture.");

if (!process.env.IS_GRAPHQL_PPX_CI) {
process.exit(1);
}
}
}

if (process.env.IS_GRAPHQL_PPX_CI) {
console.log(
"graphql_ppx: IS_GRAPHQL_PPX_CI has been set, skipping moving binary in place"
);
process.exit(0);
}
if (process.env.IS_GRAPHQL_PPX_CI) {
console.log(
"graphql_ppx: IS_GRAPHQL_PPX_CI has been set, skipping moving binary in place"
);
process.exit(0);
}

if (!fs.existsSync("ppx")) {
copyFileSync(filename, "ppx");
fs.chmodSync("ppx", 0755);
}
if (!fs.existsSync(destFilename)) {
copyFileSync(filename, destFilename);
fs.chmodSync(destFilename, 0755);
}

if (!fs.existsSync("ppx.exe")) {
copyFileSync(filename, "ppx.exe");
fs.chmodSync("ppx.exe", 0755);
var destFilenameExe = destFilename + ".exe"
if (!fs.existsSync(destFilenameExe)) {
copyFileSync(filename, destFilenameExe);
fs.chmodSync(destFilenameExe, 0755);
}
}

function copyFileSync(source, dest) {
Expand Down

0 comments on commit adbb935

Please sign in to comment.