From 2143bc7b77dfa325525b5cef81bcb86ae3986c3b Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Wed, 13 Jul 2016 14:06:05 -0700 Subject: [PATCH] improve workflow --- README.md | 14 +------------- install.sh => scripts/install.sh | 0 package.sh => scripts/package.sh | 0 session.js | 13 ++++++++++++- 4 files changed, 13 insertions(+), 14 deletions(-) rename install.sh => scripts/install.sh (100%) rename package.sh => scripts/package.sh (100%) diff --git a/README.md b/README.md index d1f9ddde..74e9cf9d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ To install `package.json` dependencies in a way where the native modules are built with `electron`, run: ```bash -$ ./install.sh +$ ./scripts/install.sh ``` Then, you want to make sure `app/dist` is populated. I recommend @@ -26,15 +26,3 @@ $ npm start ``` ...to launch the app! - -## Common Errors - -### `Error: Module version mismatch. Expected 48, got 47` - -If you get this error after `npm start`, simply remove the `node_modules` folder and try to install again using following command: - -``` -sudo ./install.sh -``` - -More details: https://github.com/zeit/hyperterm/issues/72 diff --git a/install.sh b/scripts/install.sh similarity index 100% rename from install.sh rename to scripts/install.sh diff --git a/package.sh b/scripts/package.sh similarity index 100% rename from package.sh rename to scripts/package.sh diff --git a/session.js b/session.js index 67257b01..8f161225 100644 --- a/session.js +++ b/session.js @@ -1,8 +1,19 @@ const { EventEmitter } = require('events'); -const { spawn } = require('child_pty'); const { exec } = require('child_process'); const defaultShell = require('default-shell'); +let spawn; +try { + spawn = require('child_pty').spawn; +} catch (err) { + console.error( + 'A native module failed to load. Typically this means ' + + 'you installed the modules incorrectly.\n Use `scripts/install.sh` ' + + 'to trigger the installation.\n ' + + 'More information: https://github.com/zeit/hyperterm/issues/72' + ); +} + const TITLE_POLL_INTERVAL = 500; module.exports = class Session extends EventEmitter {