Skip to content

Commit ed6359c

Browse files
committed
cleanup & path fixes
1 parent df473d6 commit ed6359c

File tree

11 files changed

+189
-141
lines changed

11 files changed

+189
-141
lines changed

lib/actions/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict';
1+
"use strict";
22
var Type = require('./actionTypes');
33
var _base_1 = require('../_base');
44
var package_1 = require('../services/package');

lib/components/menu/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var default_1 = (function (_super) {
6969
routeToProjects: function () { return dispatch(Action.setRoute('projects')); },
7070
quit: function () {
7171
render_1.togglePanel();
72-
subscriptions_1.onDeactivateSubscriptionsAndUnmount();
72+
subscriptions_1.onDeactivate();
7373
}
7474
};
7575
}),

lib/services/package.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var path = require('path');
3-
var setGlobals_1 = require('./setGlobals');
3+
var set_globals_1 = require('./set-globals');
44
var Action = require('../actions/actions');
55
var _base_1 = require('../_base');
66
var _ = require('lodash');
@@ -31,7 +31,7 @@ var PackageService = (function () {
3131
PackageService.prototype.selectPackage = function (packageName) {
3232
var packagePath = path.join(window.coderoad.dir, 'node_modules', packageName);
3333
this.config = require(path.join(packagePath, 'package.json'));
34-
setGlobals_1.setGlobals(this.config);
34+
set_globals_1.setGlobals(this.config);
3535
this.data = require(path.join(packagePath, this.config.main));
3636
this.packageName = packageName;
3737
};

lib/services/set-globals.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use strict";
2+
var path = require('path');
3+
var exists_1 = require('./exists');
4+
function setGlobals(config) {
5+
window.coderoad = Object.assign(window.coderoad, {
6+
tutorial: config.name,
7+
suffix: config.config.testSuffix.substring(config.config.testSuffix.lastIndexOf('.') + 1, config.config.testSuffix.length),
8+
tutorialDir: path.join(window.coderoad.dir, 'node_modules', config.name, config.config.testDir),
9+
testRunner: config.config.testRunner,
10+
testRunnerOptions: config.config.testRunnerOptions || {}
11+
});
12+
loadRepo(config);
13+
loadRunnerDep(config);
14+
}
15+
exports.setGlobals = setGlobals;
16+
function loadRunnerDep(config) {
17+
var flatDep = path.join(window.coderoad.dir, 'node_modules', config.config.testRunner, 'package.json');
18+
var treeDep = path.join(window.coderoad.dir, 'node_modules', config.name, 'node_modules', config.config.testRunner, 'package.json');
19+
var runnerMain;
20+
var runnerRoot;
21+
if (exists_1.fileExists(flatDep)) {
22+
runnerMain = require(flatDep).main;
23+
runnerRoot = flatDep;
24+
}
25+
else if (exists_1.fileExists(treeDep)) {
26+
runnerMain = require(treeDep).main;
27+
runnerRoot = treeDep;
28+
}
29+
else {
30+
var message = 'Error loading test runner. Post an issue. https://github.com/coderoad/atom-coderoad/issues';
31+
console.log(message);
32+
throw message;
33+
}
34+
var slash = window.coderoad.win ? '\\' : '/';
35+
runnerMain = path.join.apply(null, runnerMain.split(slash));
36+
runnerRoot = runnerRoot.substring(0, runnerRoot.lastIndexOf(slash));
37+
var pathToMain = path.join(runnerRoot, runnerMain);
38+
if (!!require(pathToMain).default) {
39+
window.coderoad.runner = require(pathToMain).default;
40+
}
41+
else {
42+
window.coderoad.runner = require(pathToMain);
43+
}
44+
}
45+
function loadRepo(config) {
46+
if (config.bugs && config.bugs.url) {
47+
window.coderoad.issuesPath = config.bugs.url;
48+
}
49+
if (config.repo && config.repo.url) {
50+
var repo = config.repo.url;
51+
if (!!repo.match(/\.git$/)) {
52+
repo = repo.slice(0, repo.length - 4);
53+
}
54+
window.coderoad.repo = repo;
55+
}
56+
window.coderoad.edit = config.config.edit && !!window.coderoad.repo || false;
57+
}

src/actions/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
import * as Type from './actionTypes';
32
import {store} from '../_base';
43
import Package from '../services/package';

src/components/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as React from 'react';
33
import {connect} from 'react-redux';
44
import * as Action from '../../actions/actions';
55
import {togglePanel} from '../render';
6-
import {onDeactivateSubscriptionsAndUnmount} from '../../atom/subscriptions';
6+
import {onDeactivate} from '../../atom/subscriptions';
77

88
import {AppBar, IconButton, IconMenu, MenuItem, Divider} from 'material-ui';
99
let MoreVertIcon = require('material-ui/lib/svg-icons/navigation/more-vert');
@@ -26,7 +26,7 @@ let NavigationClose = require('material-ui/lib/svg-icons/navigation/close');
2626
routeToProjects: () => dispatch(Action.setRoute('projects')),
2727
quit: () => {
2828
togglePanel();
29-
onDeactivateSubscriptionsAndUnmount();
29+
onDeactivate();
3030
}
3131
};
3232
})

src/services/package.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import {setGlobals} from './setGlobals';
2+
import {setGlobals} from './set-globals';
33
import * as Action from '../actions/actions';
44
import {store} from '../_base';
55
const _ = require('lodash');
File renamed without changes.

src/typings/cr/cr.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ declare namespace CR {
101101
interface Coderoad {
102102
dir: string;
103103
testRunner?: string;
104-
suffix: string;
104+
suffix?: string;
105105
tutorial?: string;
106106
tutorialDir?: string;
107107
tutorialOptions?: Object;

src/typings/tsd.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
/// <reference path="assertion-error/assertion-error.d.ts" />
22
/// <reference path="atom/atom.d.ts" />
3-
/// <reference path="chai/chai.d.ts" />
43
/// <reference path="classnames/classnames.d.ts" />
54
/// <reference path="es6-promise/es6-promise.d.ts" />
6-
/// <reference path="mocha/mocha.d.ts" />
75
/// <reference path="node/node.d.ts" />
86
/// <reference path="react-dom/react-dom.d.ts" />
97
/// <reference path="react-redux/react-redux.d.ts" />
108
/// <reference path="react/react-addons-css-transition-group.d.ts" />
119
/// <reference path="react/react.d.ts" />
12-
/// <reference path="redux-devtools/redux-devtools.d.ts" />
13-
/// <reference path="redux-thunk/redux-thunk.d.ts" />
1410
/// <reference path="redux/redux.d.ts" />
1511
/// <reference path="text-buffer/text-buffer.d.ts" />
1612
/// <reference path="react/react-addons-css-transition-group.d.ts" />

0 commit comments

Comments
 (0)