From 182eaf8879139186657f5d230c7fda49b271ad6e Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 25 May 2016 14:47:13 -0400 Subject: [PATCH 1/6] Launch the app after starting the dev server. --- dev_server.js | 24 ------------------------ package.json | 4 +--- script/{run => run.js} | 12 +++++++----- script/start | 31 +++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 32 deletions(-) delete mode 100644 dev_server.js rename script/{run => run.js} (50%) create mode 100644 script/start diff --git a/dev_server.js b/dev_server.js deleted file mode 100644 index 32f1a37d61..0000000000 --- a/dev_server.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict' - -const express = require('express') -const webpack = require('webpack') -const config = require('./webpack.development') - -const app = express() -const compiler = webpack(config) -const port = process.env.PORT || 3000 - -app.use(require('webpack-dev-middleware')(compiler, { - publicPath: config.output.publicPath -})) - -app.use(require('webpack-hot-middleware')(compiler)) - -app.listen(port, 'localhost', err => { - if (err) { - console.log(err) - return - } - - console.log(`Listening at http://localhost:${port}`) -}) diff --git a/package.json b/package.json index a271167e2e..844ef57558 100644 --- a/package.json +++ b/package.json @@ -13,9 +13,7 @@ "scripts": { "test": "electron-mocha --renderer --require ts-node/register test/*.ts test/*.tsx", "postinstall": "typings install", - "start-server": "node dev_server.js", - "start": "npm run build:dev && npm-run-all --parallel run start-server", - "run": "env NODE_ENV=development node script/run", + "start": "npm run build:dev && node script/start", "compile:dev": "tsc && env NODE_ENV=development webpack --config webpack.development.js", "compile:prod": "tsc && env NODE_ENV=production webpack --config webpack.production.js", "build:dev": "npm run compile:dev && env NODE_ENV=development node script/build", diff --git a/script/run b/script/run.js similarity index 50% rename from script/run rename to script/run.js index 52bb939cb3..b09b07f2bd 100644 --- a/script/run +++ b/script/run.js @@ -1,5 +1,3 @@ -#!/usr/bin/env node - 'use strict' const path = require('path') @@ -7,15 +5,19 @@ const cp = require('child_process') const distInfo = require('./dist-info') const distPath = distInfo.getDistPath() +const productName = distInfo.getProductName() let binaryPath = '' if (process.platform === 'darwin') { - binaryPath = path.join(distPath, 'GitHub.app', 'Contents', 'MacOS', 'GitHub') + binaryPath = path.join(distPath, `${productName}.app`, 'Contents', 'MacOS', `${productName}`) } else if (process.platform === 'win32') { - binaryPath = path.join(distPath, 'GitHub') + binaryPath = path.join(distPath, `${productName}`) } else { console.error(`I dunno how to run on ${process.arch} :(`) process.exit(1) } -cp.spawn(binaryPath, [], {env: process.env}) +module.exports = function () { + const env = Object.assign({}, process.env, {NODE_ENV: 'development'}) + return cp.spawn(binaryPath, [], {env}) +} diff --git a/script/start b/script/start new file mode 100644 index 0000000000..0b76615c8f --- /dev/null +++ b/script/start @@ -0,0 +1,31 @@ +'use strict' + +const express = require('express') +const webpack = require('webpack') +const config = require('../webpack.development') +const run = require('./run') + +const server = express() +const compiler = webpack(config) +const port = process.env.PORT || 3000 + +server.use(require('webpack-dev-middleware')(compiler, { + publicPath: config.output.publicPath +})) + +server.use(require('webpack-hot-middleware')(compiler)) + +server.listen(port, 'localhost', err => { + if (err) { + console.log(err) + process.exit(1) + return + } + + console.log(`Server running at http://localhost:${port}`) + + const runningApp = run() + runningApp.on('close', () => { + process.exit(0) + }) +}) From 7b588e18b0b49eb2ea16ad23781f5997d8be1475 Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 25 May 2016 14:47:17 -0400 Subject: [PATCH 2/6] Update the README --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 791dabe239..77076a3606 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,8 @@ Just playin around with some computering. npm install ``` -If you want hot loading: +To build and run the app: ``` -# Start the dev server npm start ``` - -Or if you don't care: - -``` -npm run build -npm run dev -``` From 1e7b7848bbc2fa8166bd6438e06adffea10fa8c8 Mon Sep 17 00:00:00 2001 From: joshaber Date: Wed, 25 May 2016 14:48:01 -0400 Subject: [PATCH 3/6] Don't need run-all anymore. --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 844ef57558..49c6204282 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "express": "^4.13.4", "fs-extra": "^0.30.0", "mocha": "^2.4.5", - "npm-run-all": "^1.8.0", "react-addons-test-utils": "^15.0.2", "ts-loader": "^0.8.2", "ts-node": "^0.7.2", From 6b5cc2ab276c591f0294b417fd4c2baf285e6b9c Mon Sep 17 00:00:00 2001 From: joshaber Date: Fri, 27 May 2016 10:46:23 -0400 Subject: [PATCH 4/6] Use the node --- script/start | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/start b/script/start index 0b76615c8f..8cbb31eb3d 100644 --- a/script/start +++ b/script/start @@ -1,3 +1,5 @@ +#!/usr/bin/env node + 'use strict' const express = require('express') From c120e8f7c64049b9c8fa9f39f2167f05dfff440e Mon Sep 17 00:00:00 2001 From: joshaber Date: Fri, 27 May 2016 11:53:09 -0400 Subject: [PATCH 5/6] Build on OS X --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index bcb67c8857..e2ec2a3c0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ notifications: on_success: never on_failure: change +os: + - osx + branches: only: - master @@ -21,17 +24,14 @@ addons: packages: - g++-4.8 +cache: + directories: + - node_modules + install: - npm install -before_script: - - export DISPLAY=:99.0; sh -e /etc/init.d/xvfb start - script: - npm run lint - npm run build:prod - npm test - -cache: - directories: - - node_modules From 8f49ee2cf9013d5b52972d81bcb69b032409107d Mon Sep 17 00:00:00 2001 From: joshaber Date: Fri, 27 May 2016 12:09:04 -0400 Subject: [PATCH 6/6] Pin to 1.1.3 exactly. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da66d7316c..4de2c5a523 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "chai": "^3.5.0", "electron-mocha": "2.1.0", "electron-packager": "^7.0.1", - "electron-prebuilt": "^1.1.2", + "electron-prebuilt": "1.1.3", "electron-winstaller": "^2.3.0", "express": "^4.13.4", "fs-extra": "^0.30.0",