Skip to content

Commit

Permalink
Fix Core not having node_modules (#698)
Browse files Browse the repository at this point in the history
* add `after-pack` script for macOS

* Revert "add `after-pack` script for macOS"

This reverts commit 5c67ca0.

* move core to ./core

* refactor

* fix lint

* docs
  • Loading branch information
juliangruber authored May 12, 2023
1 parent a1a7b57 commit b8d635d
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 354 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"ignorePatterns": [
"assets/",
"dist/",
"@types/"
"@types/",
"core/"
],
"overrides": [
{
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ dev-app-update.yml
*.sln
*.sw?
.tool-versions

core
3 changes: 2 additions & 1 deletion electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ files:
- node_modules/**/*
- package.json

asarUnpack: 'main/**/scripts/**/*'
extraResources:
- 'core/**'

beforePack: './build/before-pack.js'
afterSign: './build/notarize-macos.js'
Expand Down
17 changes: 5 additions & 12 deletions main/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ const { Core } = require('@filecoin-station/core')
/** @typedef {import('./typings').Context} Context */
/** @typedef {import('./typings').Activity} Activity */

// When packaged, `app.getAppPath()` points to the ASAR archive. We need to
// rewrite that path to the unpacked ASAR directory, where `electron-builder`
// automatically extracted Core for us. Otherwise, Core wouldn't be able to
// execute its binaries.
const corePath = join(
app.getAppPath(),
'node_modules',
'@filecoin-station',
'core',
'bin',
'station.js'
).replace('app.asar', 'app.asar.unpacked')
// Core is installed separately from `node_modules`, since it needs a
// self-contained dependency tree outside the asar archive.
const corePath = app.isPackaged
? join(process.resourcesPath, 'core', 'bin', 'station.js')
: join(__dirname, '..', 'core', 'bin', 'station.js')
console.log('Core binary: %s', corePath)

let online = false
Expand Down
Loading

0 comments on commit b8d635d

Please sign in to comment.