Skip to content

Commit

Permalink
⚡ Fix app build
Browse files Browse the repository at this point in the history
- Remove Array.findIndex polyfill
- Fix test runner
- Update .travis.yml to run node v5
  • Loading branch information
stefanbuck authored and ruyadorno committed Jan 24, 2016
1 parent 78a5dd1 commit 1d35ecd
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 45 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
build/
cache/
.cache/
node_modules
npm-debug.log
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: node_js
node_js:
- '0.10'
- '0.12'
- 'stable'
- v5
before_install:
- "sh -e /etc/init.d/xvfb start"
env:
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
"main": "src/browser/main.js",
"bugs": "https://github.com/yeoman/yeoman-app/issues",
"dependencies": {
"array.prototype.findindex": "^1.0.0",
"async": "^1.2.1",
"bootstrap": "^3.3.0",
"color": "^0.8.0",
"electron-compile": "^1.0.0",
"electron-compile": "^2.0.5",
"findup-sync": "^0.2.1",
"fix-path": "^1.1.0",
"flux": "^2.0.1",
Expand All @@ -39,9 +38,12 @@
"yeoman-environment": "^1.2.5"
},
"devDependencies": {
"electron-compilers": "^2.0.4",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"electron-compilers": "^2.0.5",
"electron-packager": "^5.2.0",
"electron-prebuilt": "0.36.3",
"electron-prebuilt": "0.36.4",
"eslint": "^1.10.2",
"eslint-plugin-react": "^3.10.0",
"minimist": "^1.1.1",
Expand All @@ -62,7 +64,7 @@
"preinspector": "open http://127.0.0.1:8080/?ws=127.0.0.1:8080&port=5858",
"inspector": "node-inspector",
"lint": "eslint --ext=js --ext=jsx src spec",
"build": "electron-compile --target ./cache src/ static/ && node scripts/build.js"
"build": "electron-compile --appDir . ./src/ ./static/ && node scripts/build.js"
},
"license": "MIT",
"repository": {
Expand Down
13 changes: 6 additions & 7 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/env node

var path = require('path');
var proc = require('child_process')
var electron = require('electron-prebuilt')
const path = require('path');
const proc = require('child_process');

var args = [path.resolve(__dirname, '..'), '-r', '--test'];
var opts = { stdio: 'inherit' };
var child = proc.spawn(electron, args, opts);
const args = [path.resolve(__dirname, '..'), '-r', '--test'];
const opts = { stdio: 'inherit' };
const child = proc.spawn('electron', args, opts);

child.on('exit', function (exitCode) {
child.on('exit', (exitCode) => {
process.exit(exitCode);
});
2 changes: 2 additions & 0 deletions spec/helpers/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ if (global.loadSettings.exitWhenDone) {
link.rel = 'stylesheet';
link.href = '../vendor/jasmine/lib/jasmine-2.1.3/jasmine.css';
document.head.appendChild(link);

window.getJasmineRequireObj = undefined;
window.jasmineRequire = require('../../vendor/jasmine/lib/jasmine-2.1.3/jasmine');
require('../../vendor/jasmine/lib/jasmine-2.1.3/jasmine-html');
require('../../vendor/jasmine/lib/jasmine-2.1.3/boot');
Expand Down
2 changes: 1 addition & 1 deletion spec/insight-spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Insight = require('../src/renderer/utils/insight.js');
import Insight from '../src/renderer/utils/insight.js';

describe('Insight', function () {

Expand Down
14 changes: 7 additions & 7 deletions src/browser/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var yargs = require('yargs');
import yargs from 'yargs';
import application from './application';

var shellStartTime = Date.now();
const shellStartTime = Date.now();

process.on('uncaughtException', function (error) {
process.on('uncaughtException', (error) => {
if (!error) {
error = {};
}
Expand All @@ -14,17 +15,16 @@ process.on('uncaughtException', function (error) {
}
});

var args = parseCommandLine();
require('./application')(args);
application(parseCommandLine());

console.log('App load time: ' + (Date.now() - shellStartTime) + 'ms');

function parseCommandLine() {
var options = yargs(process.argv.slice(1)).wrap(100);
const options = yargs(process.argv.slice(1)).wrap(100);

options.alias('t', 'test').boolean('t').describe('t', 'Run the specs and exit with error code on failures.');

var argv = options.argv;
const argv = options.argv;

return {
test: argv.test
Expand Down
22 changes: 5 additions & 17 deletions src/browser/main.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
var app = require('app');
var path = require('path');
var fs = require('fs');
const path = require('path');
const electron = require('electron');
const app = electron.app;

// ROOT/src/browser/../../cache
var cachePath = path.join(__dirname, '..', '..', 'cache');
var devMode = (process.argv || []).indexOf('-r') !== -1;

// Note: It's important that you don't do anything with Electron
// unless it's after 'ready', or else mysterious bad things will happen
// to you.
app.on('ready', function () {
// Enable ES6 from this point on
if (fs.statSyncNoException(cachePath) && !devMode) {
require('electron-compile').initForProduction(cachePath);
} else {
require('electron-compile').init();
}

require('./app');
const appRoot = path.join(__dirname, '..', '..');
require('electron-compile').init(appRoot, './app');
});
9 changes: 4 additions & 5 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/*global React*/

import insight from './utils/insight';
import Root from './containers/root.jsx';

const header = document.createElement('header');
Object.assign(header.style, {
background: '#FFDE00 url("./img/header.png") no-repeat scroll top center',
Expand All @@ -21,13 +24,9 @@ style.type = 'text/css';
style.href = 'fonts.css';
document.head.appendChild(style);

// Array.prototype.findIndex polyfill, we can remove this as soon as Chrome starts supporting it
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex
require('array.prototype.findindex');

require('./utils/insight').init(function () {
insight.init(function () {
// React entry-point
const Root = require('./containers/root.jsx');

React.render(<Root />, document.getElementById('content'));
});

0 comments on commit 1d35ecd

Please sign in to comment.