Skip to content

Commit ffa81b0

Browse files
committed
coerce checks into bools
1 parent 61bdd7c commit ffa81b0

File tree

8 files changed

+23
-14
lines changed

8 files changed

+23
-14
lines changed

lib/atom/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
var render_1 = require('../components/render');
33
var polyfills_1 = require('../services/polyfills');
44
var subscriptions_1 = require('./subscriptions');
5+
var store_1 = require('../store/store');
6+
var Action = require('../actions/actions');
57
function setDir() {
68
if (atom.project.rootDirectories.length > 0) {
79
return atom.project.rootDirectories[0].path;
@@ -15,11 +17,12 @@ function setWin() {
1517
}
1618
var Main = (function () {
1719
function Main() {
20+
polyfills_1.default();
1821
window.coderoad = {
1922
dir: setDir(),
2023
win: setWin()
2124
};
22-
polyfills_1.default();
25+
store_1.store.dispatch(Action.verifySetup());
2326
this.root = render_1.initRoot();
2427
}
2528
Main.prototype.activate = function () {

lib/reducers/checks/check-system.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
var command_line_1 = require('../../services/command-line');
3+
var minVersion = 3;
34
function npmVersionThreeOrLater() {
4-
var minVersion = 3;
55
return new Promise(function (resolve, reject) {
66
var threeOrLater = command_line_1.default('npm', '-v').then(function (res) { return parseInt(res, 10) >= minVersion; });
77
if (!threeOrLater) {

lib/reducers/checks/setup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ function verifySetup() {
1414
var checks = {
1515
system: {
1616
node: true,
17-
npm: check_system_1.npmVersionThreeOrLater().then(result)
17+
npm: !!check_system_1.npmVersionThreeOrLater()
1818
},
1919
setup: {
20-
dir: check_setup_1.hasDirectory().then(result),
21-
packageJson: check_setup_1.hasPackageJson().then(result),
22-
tutorial: check_setup_1.hasTutorialDep().then(result)
20+
dir: !!check_setup_1.hasDirectory(),
21+
packageJson: !!check_setup_1.hasPackageJson(),
22+
tutorial: !!check_setup_1.hasTutorialDep()
2323
}
2424
};
2525
checks.passed = verified(checks);

src/atom/main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import {render, initRoot, togglePanel} from '../components/render';
44
import loadPolyfills from '../services/polyfills';
55
import {onActivate, onDeactivate, addToStatusBar} from './subscriptions';
66

7+
import {store} from '../store/store';
8+
import * as Action from '../actions/actions';
9+
10+
// TODO: find a better place to load globals
11+
712
function setDir(): string {
813
if (atom.project.rootDirectories.length > 0) {
914
return atom.project.rootDirectories[0].path;
@@ -19,11 +24,12 @@ class Main {
1924
root: HTMLElement;
2025
statusBarTile: StatusBar.IStatusBarView;
2126
constructor() {
27+
loadPolyfills(); // remove with later version of Chrome
2228
window.coderoad = {
2329
dir: setDir(),
2430
win: setWin()
2531
};
26-
loadPolyfills();
32+
store.dispatch(Action.verifySetup());
2733
this.root = initRoot();
2834
}
2935
activate(): void {

src/reducers/checks/check-system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import commandLine from '../../services/command-line';
22

3+
const minVersion = 3;
34
export function npmVersionThreeOrLater(): Promise<boolean> {
4-
const minVersion = 3;
55
return new Promise((resolve, reject) => {
66
let threeOrLater: Promise<boolean> = commandLine('npm', '-v').then((res: string) => parseInt(res, 10) >= minVersion);
77
if (!threeOrLater) {

src/reducers/checks/setup.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ export default function verifySetup(): CR.Checks {
2121
let checks: CR.Checks = {
2222
system: {
2323
node: true,
24-
npm: npmVersionThreeOrLater().then(result)
24+
npm: !!npmVersionThreeOrLater()
2525
},
2626
setup: {
27-
dir: hasDirectory().then(result),
28-
packageJson: hasPackageJson().then(result),
29-
tutorial: hasTutorialDep().then(result)
27+
dir: !!hasDirectory(),
28+
packageJson: !!hasPackageJson(),
29+
tutorial: !!hasTutorialDep()
3030
}
3131
};
3232

src/reducers/globals/globals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Type from '../../actions/actionTypes';
2-
import {setWin, setGlobals} from './set-globals';
2+
import {setGlobals} from './set-globals';
33

44
// TODO: refactor out globals into state
55

src/reducers/tutorials/check-tutorials.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {canUpdateTutorial} from './update-tutorial';
77
let tutorialError = 'This is an error with the tutorial itself';
88

99
export function packageJsonExists(): boolean {
10-
console.log('packageJsonExists?')
10+
console.log('packageJsonExists?');
1111
const pathToPackageJson = path.join(window.coderoad.dir, 'package.json');
1212
return fileExists(pathToPackageJson);
1313
}

0 commit comments

Comments
 (0)