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 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 -``` 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 da66d7316c..d792e96d4b 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", @@ -50,12 +48,11 @@ "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", "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", 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..8cbb31eb3d --- /dev/null +++ b/script/start @@ -0,0 +1,33 @@ +#!/usr/bin/env node + +'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) + }) +})