Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #13 from gatsbyjs/fix/windows-fixes
Browse files Browse the repository at this point in the history
Fix windows paths
  • Loading branch information
ascorbic authored Aug 7, 2020
2 parents 175b9f2 + 7c8dd1f commit 84fcaa8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is alpha software, is under active development, and is likely to be broken.

### To install built packages:

1. Click on releases and choose the installer for your platform. Mac users will need to right-click (or ctrl-click) on the app when you first launch it, until we have code signing set up.
1. Click on [releases](https://github.com/gatsbyjs/desktop/releases) and choose the installer for your platform. Mac users will need to right-click (or ctrl-click) on the app when you first launch it, until we have code signing set up. Windows users will need to agree to lots of Defender warnings.

### To install from source:

Expand All @@ -24,7 +24,7 @@ This is alpha software, is under active development, and is likely to be broken.

Gatsby Desktop is an Electron app, which is currently just displayed in the menubar or tray. All Electron apps have two primary processes:

1. "main", which is a Node.js script which handles windowing, menus and similar native bits. Think of it as the server. It opens BrowserWindows which contain:
1. "main", which is a Node.js script which handles windowing, menus and similar native bits. Think of it as the server. It opens `BrowserWindow`s which contain:
2. "renderer": this is the UI of the app, which is HTML + JS. In Gatsby Desktop, this is of course a local Gatsby site. Unlike a regular web app, Electron renderers can import and use built-in Node.js modules, such as `fs` and `child_process`.

Gatsby Desktop can launch and run your local Gatsby sites. To do this we use another process:
Expand Down
Binary file modified assets/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-desktop",
"description": "Gatsby Desktop",
"version": "0.0.1-alpha.3",
"version": "0.0.1-alpha.4",
"main": "lib/main.js",
"homepage": "https://www.gatsbyjs.com/",
"author": "<[email protected]>",
Expand Down
19 changes: 15 additions & 4 deletions worker/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ async function readJSON<T = unknown>(filePath: string): Promise<T> {
})
}

// Gatsby package type is missing these
type PackageJsonWithBin = PackageJson & { bin: { gatsby: string } }

async function getPackageJson(root: string): Promise<PackageJsonWithBin> {
return readJSON<PackageJsonWithBin>(
`${root}/node_modules/gatsby/package.json`
)
}

async function isGatsbySite(root: string): Promise<boolean> {
try {
const packageJson = await readJSON<PackageJson>(
`/${root}/node_modules/gatsby/package.json`
)
const packageJson = await getPackageJson(root)
return packageJson?.name === `gatsby`
} catch (e) {
console.warn({ e })
Expand Down Expand Up @@ -95,7 +102,11 @@ async function launchSite(program: IProgram): Promise<number> {

logAction({ type: `SET_PORT`, payload: port })

const cmd = path.join(program.directory, `node_modules`, `.bin`, `gatsby`)
const packageJson = await getPackageJson(program.directory)

const bin = packageJson?.bin?.gatsby || `dist/bin/gatsby.js`

const cmd = path.resolve(program.directory, `node_modules`, `gatsby`, bin)

// Runs `gatsby develop` in the site root
proc = fork(cmd, [`develop`, `--port=${port}`], {
Expand Down

0 comments on commit 84fcaa8

Please sign in to comment.