Skip to content

Commit 65ff242

Browse files
committed
rename global.coderoad -> window.coderoad
1 parent 885d5d2 commit 65ff242

File tree

24 files changed

+63
-64
lines changed

24 files changed

+63
-64
lines changed

lib/actions/tutorials.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ var Type = require('./actionTypes');
77
var exists_1 = require('../services/exists');
88
function loadTutorials() {
99
var tutorials = [];
10-
if (global.coderoad.dir) {
10+
if (window.coderoad.dir) {
1111
var packageJson = loadRootPackageJson();
1212
if (!packageJson) {
13-
global.coderoad.package = null;
13+
window.coderoad.package = null;
1414
var message = 'No package.json file available. Try running "npm init --y" in terminal';
1515
console.log(message);
1616
_base_1.store.dispatch(Action.toggleAlert({ message: message, action: 'tip', duration: 6000 }));
@@ -25,18 +25,18 @@ function loadTutorials() {
2525
}
2626
exports.loadTutorials = loadTutorials;
2727
function loadRootPackageJson() {
28-
var pathToPackageJson = path.join(global.coderoad.dir, 'package.json');
28+
var pathToPackageJson = path.join(window.coderoad.dir, 'package.json');
2929
if (exists_1.fileExists(pathToPackageJson)) {
3030
return JSON.parse(fs.readFileSync(pathToPackageJson, 'utf8'));
3131
}
3232
return false;
3333
}
3434
function isTutorial(name) {
35-
var pathToTutorialPackageJson = path.join(global.coderoad.dir, 'node_modules', name, 'package.json');
35+
var pathToTutorialPackageJson = path.join(window.coderoad.dir, 'node_modules', name, 'package.json');
3636
if (exists_1.fileExists(pathToTutorialPackageJson)) {
3737
var packageJson = JSON.parse(fs.readFileSync(pathToTutorialPackageJson, 'utf8'));
3838
if (packageJson.main && packageJson.main.match(/coderoad.json$/)) {
39-
var pathToCoderoadJson = path.join(global.coderoad.dir, 'node_modules', name, packageJson.main);
39+
var pathToCoderoadJson = path.join(window.coderoad.dir, 'node_modules', name, packageJson.main);
4040
if (exists_1.fileExists(pathToCoderoadJson)) {
4141
return true;
4242
}

lib/atom/editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ var _base_1 = require('../_base');
33
var Action = require('../actions/actions');
44
function setAtomGlobals() {
55
if (atom.project.rootDirectories.length > 0) {
6-
global.coderoad.dir = atom.project.rootDirectories[0].path;
6+
window.coderoad.dir = atom.project.rootDirectories[0].path;
77
}
88
else {
99
var message = 'Create a new Atom project. In Atom: File > Open > any folder';
1010
_base_1.store.dispatch(Action.toggleAlert({ message: message, action: 'tip', duration: 6000 }));
1111
console.log(message);
12-
global.coderoad.dir = false;
12+
window.coderoad.dir = null;
1313
}
1414
}
1515
exports.setAtomGlobals = setAtomGlobals;

lib/atom/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var subscriptions_1 = require('./subscriptions');
55
var editor_1 = require('./editor');
66
var Main = (function () {
77
function Main() {
8-
global.coderoad = {};
8+
window.coderoad = {};
99
polyfills_1.default();
1010
editor_1.setAtomGlobals();
1111
this.root = render_1.initRoot();

lib/components/menu/menu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ var default_1 = (function (_super) {
5757
React.createElement(MoreVertIcon, null)
5858
), targetOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'top' }},
5959
this.menuOptions(),
60-
global.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, null,
61-
React.createElement("a", {href: global.coderoad.issuesPath}, "post issue")
60+
window.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, null,
61+
React.createElement("a", {href: window.coderoad.issuesPath}, "post issue")
6262
) : null,
6363
React.createElement(material_ui_1.Divider, null),
6464
React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onClick: this.props.quit}))}));

lib/components/page/edit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
2+
var React = require('react');
23
var path = require('path');
34
var Edit = require('material-ui/lib/svg-icons/editor/mode-edit');
45
Object.defineProperty(exports, "__esModule", { value: true });
56
exports.default = function (editPath) {
6-
if (editPath && global.coderoad.edit) {
7-
var repoPath = path.join(global.coderoad.repo, 'edit', 'master', editPath);
7+
if (editPath && window.coderoad.edit) {
8+
var repoPath = path.join(window.coderoad.repo, 'edit', 'master', editPath);
89
return React.createElement("a", {href: repoPath},
910
React.createElement(Edit, {style: { position: 'absolute', top: '10px', right: '10px' }})
1011
);

lib/components/projects/projects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var Projects = (function (_super) {
4242
React.createElement("p", {className: 'tagline'}, "Tutorials in the Editor"),
4343
React.createElement("div", {className: 'cr-tutorials'},
4444
React.createElement(material_ui_1.List, {subheader: 'Tutorials'},
45-
global.coderoad.dir ? null : React.createElement(material_ui_1.ListItem, {primaryText: 'Create an Atom Project', secondaryText: 'File > Open > any older'}),
45+
window.coderoad.dir ? null : React.createElement(material_ui_1.ListItem, {primaryText: 'Create an Atom Project', secondaryText: 'File > Open > any older'}),
4646
this.props.tutorials.length > 0 ?
4747
this.props.tutorials.map(function (tutorial) {
4848
return (React.createElement(material_ui_1.ListItem, {primaryText: _this.trim(tutorial), onClick: _this.props.selectProject.bind(_this, tutorial)}));

lib/components/render.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function initRoot(canStart) {
2121
var root = document.createElement('div');
2222
root.setAttribute('id', rootName);
2323
root.hidden = true;
24-
if (!!global.coderoad.dir) {
24+
if (!!window.coderoad.dir) {
2525
_base_1.store.dispatch(Action.loadTutorials());
2626
}
2727
return root;

lib/reducers/run-tests/run.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ var _base_1 = require('../../_base');
44
function runTaskTests(setup) {
55
var tests = _base_1.store.getState().taskTests;
66
if (tests && tests.length) {
7-
var config = global.coderoad;
7+
var config = window.coderoad;
88
config.taskPosition = _base_1.store.getState().taskPosition;
9-
global.coderoad.runner(tests, config, test_result_1.handleResult, test_result_1.handleLog);
9+
window.coderoad.runner(tests, config, test_result_1.handleResult, test_result_1.handleLog);
1010
}
1111
return true;
1212
}

lib/reducers/task-tests/task-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function taskTestsReducer(taskTests, action) {
66
if (taskTests === void 0) { taskTests = ''; }
77
switch (action.type) {
88
case Type.SET_PAGE:
9-
var target = path.join(global.coderoad.tutorialDir || global.coderoad.dir, '.tmp.js');
9+
var target = path.join(window.coderoad.tutorialDir || window.coderoad.dir, '.tmp.js');
1010
return concat_tests_1.concatTests(target, action.payload.taskTests);
1111
default:
1212
return taskTests;

lib/services/package.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ var _base_1 = require('../_base');
66
var _ = require('lodash');
77
function configTestString(config, packageName, test) {
88
if (config.testDir) {
9-
test = path.join(global.coderoad.dir, 'node_modules', packageName, config.testDir, test);
9+
test = path.join(window.coderoad.dir, 'node_modules', packageName, config.testDir, test);
1010
}
1111
else {
12-
test = path.join(global.coderoad.dir, 'node_modules', packageName, test);
12+
test = path.join(window.coderoad.dir, 'node_modules', packageName, test);
1313
}
1414
if (config.testSuffix) {
1515
test += config.testSuffix;
@@ -26,7 +26,7 @@ var PackageService = (function () {
2626
this.config = {};
2727
}
2828
PackageService.prototype.selectPackage = function (packageName) {
29-
var packagePath = path.join(global.coderoad.dir, 'node_modules', packageName);
29+
var packagePath = path.join(window.coderoad.dir, 'node_modules', packageName);
3030
this.config = require(path.join(packagePath, 'package.json'));
3131
setGlobals_1.setGlobals(this.config);
3232
this.data = require(path.join(packagePath, this.config.main));

lib/services/setGlobals.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
var path = require('path');
33
var exists_1 = require('./exists');
44
function setGlobals(config) {
5-
global.coderoad = Object.assign(global.coderoad, {
5+
window.coderoad = Object.assign(window.coderoad, {
66
tutorial: config.name,
7-
tutorialDir: path.join(global.coderoad.dir, 'node_modules', config.name, config.config.testDir),
7+
tutorialDir: path.join(window.coderoad.dir, 'node_modules', config.name, config.config.testDir),
88
testRunner: config.config.testRunner,
99
testRunnerOptions: config.config.testRunnerOptions || {}
1010
});
@@ -13,8 +13,8 @@ function setGlobals(config) {
1313
}
1414
exports.setGlobals = setGlobals;
1515
function loadRunnerDep(config) {
16-
var flatDep = path.join(global.coderoad.dir, 'node_modules', config.config.testRunner, 'package.json');
17-
var treeDep = path.join(global.coderoad.dir, 'node_modules', config.name, 'node_modules', config.config.testRunner, 'package.json');
16+
var flatDep = path.join(window.coderoad.dir, 'node_modules', config.config.testRunner, 'package.json');
17+
var treeDep = path.join(window.coderoad.dir, 'node_modules', config.name, 'node_modules', config.config.testRunner, 'package.json');
1818
var runnerMain;
1919
var runnerRoot;
2020
if (exists_1.fileExists(flatDep)) {
@@ -33,22 +33,22 @@ function loadRunnerDep(config) {
3333
runnerRoot = runnerRoot.substring(0, runnerRoot.lastIndexOf('/'));
3434
var pathToMain = path.join(runnerRoot, runnerMain);
3535
if (!!require(pathToMain).default) {
36-
global.coderoad.runner = require(pathToMain).default;
36+
window.coderoad.runner = require(pathToMain).default;
3737
}
3838
else {
39-
global.coderoad.runner = require(pathToMain);
39+
window.coderoad.runner = require(pathToMain);
4040
}
4141
}
4242
function loadRepo(config) {
4343
if (config.bugs && config.bugs.url) {
44-
global.coderoad.issuesPath = config.bugs.url;
44+
window.coderoad.issuesPath = config.bugs.url;
4545
}
4646
if (config.repo && config.repo.url) {
4747
var repo = config.repo.url;
4848
if (!!repo.match(/\.git$/)) {
4949
repo = repo.slice(0, repo.length - 4);
5050
}
51-
global.coderoad.repo = repo;
51+
window.coderoad.repo = repo;
5252
}
53-
global.coderoad.edit = config.config.edit && !!global.coderoad.repo || false;
53+
window.coderoad.edit = config.config.edit && !!window.coderoad.repo || false;
5454
}

src/actions/tutorials.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import {fileExists} from '../services/exists';
77

88
export function loadTutorials(): CR.Action {
99
let tutorials = [];
10-
if (global.coderoad.dir) {
10+
if (window.coderoad.dir) {
1111
let packageJson: PackageJson|boolean = loadRootPackageJson();
1212
if (!packageJson) {
13-
global.coderoad.package = null;
13+
window.coderoad.package = null;
1414
let message = 'No package.json file available. Try running "npm init --y" in terminal';
1515
console.log(message);
1616
store.dispatch(Action.toggleAlert({ message, action: 'tip', duration: 6000 }));
@@ -25,21 +25,21 @@ export function loadTutorials(): CR.Action {
2525

2626

2727
function loadRootPackageJson(): PackageJson|boolean {
28-
let pathToPackageJson = path.join(global.coderoad.dir, 'package.json');
28+
let pathToPackageJson = path.join(window.coderoad.dir, 'package.json');
2929
if (fileExists(pathToPackageJson)) {
3030
return JSON.parse(fs.readFileSync(pathToPackageJson, 'utf8'));
3131
}
3232
return false;
3333
}
3434

3535
function isTutorial(name): boolean {
36-
let pathToTutorialPackageJson = path.join(global.coderoad.dir, 'node_modules', name, 'package.json');
36+
let pathToTutorialPackageJson = path.join(window.coderoad.dir, 'node_modules', name, 'package.json');
3737
if (fileExists(pathToTutorialPackageJson)) {
3838
// has package.json
3939
let packageJson = JSON.parse(fs.readFileSync(pathToTutorialPackageJson, 'utf8'));
4040
// main path to coderoad.json
4141
if (packageJson.main && packageJson.main.match(/coderoad.json$/)) {
42-
let pathToCoderoadJson = path.join(global.coderoad.dir, 'node_modules', name, packageJson.main);
42+
let pathToCoderoadJson = path.join(window.coderoad.dir, 'node_modules', name, packageJson.main);
4343
// coderoad.json file exists
4444
if (fileExists(pathToCoderoadJson)) {
4545
return true;

src/atom/editor.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import * as Action from '../actions/actions';
33

44
export function setAtomGlobals() {
55
if (atom.project.rootDirectories.length > 0) {
6-
global.coderoad.dir = atom.project.rootDirectories[0].path;
6+
window.coderoad.dir = atom.project.rootDirectories[0].path;
77
} else {
88
let message = 'Create a new Atom project. In Atom: File > Open > any folder';
99
store.dispatch(Action.toggleAlert({ message, action: 'tip', duration: 6000 }));
1010
console.log(message);
11-
global.coderoad.dir = false;
11+
window.coderoad.dir = null;
1212
}
1313
}
1414

@@ -36,11 +36,6 @@ export function getEditor() {
3636
});
3737
}
3838

39-
// export function packageDir(packageName: string) {
40-
// global.coderoad.tutorialDir = path.join(global.coderoad.dir, 'node_modules', packageName);
41-
// return path.join(global.coderoad.dir, 'node_modules', packageName);
42-
// }
43-
4439
/**
4540
* Actions in Atom Editor
4641
* @return {[type]} [description]

src/atom/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Main {
99
root: HTMLElement;
1010
statusBarTile: StatusBar.IStatusBarView;
1111
constructor() {
12-
global.coderoad = {};
12+
window.coderoad = {};
1313
loadPolyfills();
1414
setAtomGlobals();
1515
this.root = initRoot();

src/components/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export default class extends React.Component<{
7474
{/* Menu Items */}
7575
{this.menuOptions()}
7676
{}
77-
{global.coderoad.issuesPath ? <MenuItem>
78-
<a href={global.coderoad.issuesPath}>
77+
{window.coderoad.issuesPath ? <MenuItem>
78+
<a href={window.coderoad.issuesPath}>
7979
post issue
8080
</a>
8181
</MenuItem> : null}

src/components/page/edit.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
import * as React from 'react';
23
import * as path from 'path';
34
const Edit = require('material-ui/lib/svg-icons/editor/mode-edit');
45

@@ -7,8 +8,8 @@ const Edit = require('material-ui/lib/svg-icons/editor/mode-edit');
78
* basic chapter info
89
*/
910
export default (editPath) => {
10-
if (editPath && global.coderoad.edit) {
11-
let repoPath = path.join(global.coderoad.repo, 'edit', 'master', editPath);
11+
if (editPath && window.coderoad.edit) {
12+
let repoPath = path.join(window.coderoad.repo, 'edit', 'master', editPath);
1213
return <a href={repoPath}>
1314
<Edit style={{position: 'absolute', top: '10px', right: '10px'}}/>
1415
</a>;

src/components/projects/projects.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class Projects extends React.Component<{
4646
<div className='cr-tutorials'>
4747
<List subheader='Tutorials' >
4848

49-
{global.coderoad.dir ? null : <ListItem
49+
{window.coderoad.dir ? null : <ListItem
5050
primaryText='Create an Atom Project'
5151
secondaryText='File > Open > any older' /> }
5252

src/components/render.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function initRoot(canStart: boolean) {
3333
root.setAttribute('id', rootName);
3434
// mark panel visibility as hidden, triggers immediately
3535
root.hidden = true;
36-
if (!!global.coderoad.dir) {
36+
if (!!window.coderoad.dir) {
3737
store.dispatch(Action.loadTutorials());
3838
}
3939
return root;

src/reducers/run-tests/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {store} from '../../_base';
44
export function runTaskTests(setup?: boolean): boolean {
55
const tests: CR.TaskTest[] = store.getState().taskTests;
66
if (tests && tests.length) {
7-
let config = global.coderoad;
7+
let config = window.coderoad;
88
config.taskPosition = store.getState().taskPosition;
99
// call test runner
10-
global.coderoad.runner(tests, config, handleResult, handleLog);
10+
window.coderoad.runner(tests, config, handleResult, handleLog);
1111
}
1212
return true;
1313
}

src/reducers/task-tests/task-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {concatTests} from './concat-tests';
66
export default function taskTestsReducer(taskTests = '', action: CR.Action): string {
77
switch (action.type) {
88
case Type.SET_PAGE:
9-
let target = path.join(global.coderoad.tutorialDir || global.coderoad.dir, '.tmp.js');
9+
let target = path.join(window.coderoad.tutorialDir || window.coderoad.dir, '.tmp.js');
1010
return concatTests(target, action.payload.taskTests);
1111
default:
1212
return taskTests;

src/services/package.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ const _ = require('lodash');
66

77
function configTestString(config: PackageJson.config, packageName: string, test: string): string {
88
if (config.testDir) {
9-
test = path.join(global.coderoad.dir, 'node_modules', packageName, config.testDir, test);
9+
test = path.join(window.coderoad.dir, 'node_modules', packageName, config.testDir, test);
1010
} else {
11-
test = path.join(global.coderoad.dir, 'node_modules', packageName, test);
11+
test = path.join(window.coderoad.dir, 'node_modules', packageName, test);
1212
}
1313
if (config.testSuffix) {
1414
test += config.testSuffix;
@@ -29,7 +29,7 @@ class PackageService {
2929
this.config = {};
3030
}
3131
selectPackage(packageName: string) {
32-
let packagePath = path.join(global.coderoad.dir, 'node_modules', packageName);
32+
let packagePath = path.join(window.coderoad.dir, 'node_modules', packageName);
3333
this.config = require(path.join(packagePath, 'package.json'));
3434
setGlobals(this.config);
3535
this.data = require(path.join(packagePath, this.config.main));

0 commit comments

Comments
 (0)