Skip to content

Commit

Permalink
avoid ENOENT error when rebuilding deps
Browse files Browse the repository at this point in the history
Without this fix, I frequently get the following error:

```

node:fs:3003
  binding.copyFile(
          ^

Error: ENOENT: no such file or directory, copyfile '/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/ppx-macos-latest' -> '/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/ppx'
    at Object.copyFileSync (node:fs:3003:11)
    at copyPlatformBinaries (/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/postinstall.js:102:6)
    at Object.<anonymous> (/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/postinstall.js:177:7)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'copyfile',
  path: '/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/ppx-macos-latest',
  dest: '/Users/paul/code/miriad/packages/web/node_modules/rescript-relay/ppx'
}

Node.js v20.10.0
```
  • Loading branch information
tsnobip committed Feb 20, 2024
1 parent 52cc9b2 commit f6a2ef6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

# **Version 3**

# 3.0.0-rc.4

- Fix an error in postinstall.js when reinstalling rescript-relay dependency (https://github.com/zth/rescript-relay/pull/487)

# 3.0.0-rc.3

- Fix issue with custom scalars in arrays not being autoconverted properly.
Expand Down
38 changes: 19 additions & 19 deletions packages/rescript-relay/scripts/release-postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,36 +99,36 @@ function copyPlatformBinaries(platform) {
/**
* Copy the PPX
*/
fs.copyFileSync(
path.join(__dirname, "ppx-" + platform),
path.join(__dirname, "ppx")
);
fs.chmodSync(path.join(__dirname, "ppx"), 0777);

// Windows seems to need an .exe file as well.
if (platform === "windows-latest") {
const ppxFinalFilename = platform === "windows-latest" ? "ppx.exe" : "ppx";
const ppxFinalPath = path.join(__dirname, ppxFinalFilename);

if (!fs.existsSync(ppxFinalPath)){
fs.copyFileSync(
path.join(__dirname, "ppx-" + platform),
path.join(__dirname, "ppx.exe")
ppxFinalPath
);
fs.chmodSync(path.join(__dirname, "ppx.exe"), 0777);
}
fs.chmodSync(ppxFinalPath, 0777);

/**
* Copy the Relay compiler
*/

var platformSuffix = getRelayCompilerPlatformSuffix();

fs.copyFileSync(
path.join(
__dirname,
"relay-compiler-" + platformSuffix,
platformSuffix === "win-x64" ? "relay.exe" : "relay"
),
path.join(__dirname, "rescript-relay-compiler.exe")
);
fs.chmodSync(path.join(__dirname, "rescript-relay-compiler.exe"), 0777);
const rescriptRelayCompilerFinalPath = path.join(__dirname, "rescript-relay-compiler.exe");

if (!fs.existsSync(rescriptRelayCompilerFinalPath)){
fs.copyFileSync(
path.join(
__dirname,
"relay-compiler-" + platformSuffix,
platformSuffix === "win-x64" ? "relay.exe" : "relay"
),
rescriptRelayCompilerFinalPath
);
}
fs.chmodSync(rescriptRelayCompilerFinalPath, 0777);
}

function removeInitialBinaries() {
Expand Down

0 comments on commit f6a2ef6

Please sign in to comment.