Skip to content

Commit 0bf9db1

Browse files
committed
various fixes, minor
1 parent 6defdf2 commit 0bf9db1

File tree

35 files changed

+121
-105
lines changed

35 files changed

+121
-105
lines changed

lib/reducers/checks/action-setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use strict";
2-
var path = require('path');
2+
var path_1 = require('path');
33
var editor_1 = require('../../atom/editor');
44
var actions_1 = require('../../atom/actions');
55
var store_1 = require('../../store/store');
66
var actions_2 = require('../../actions/actions');
77
var packageData = "{\n \"name\": \"demo\",\n \"dependencies\": {\n \"coderoad-functional-school\": \"^0.2.1\"\n }\n}";
88
function createPackageJson() {
9-
var packagePath = path.join(window.coderoad.dir, 'package.json');
9+
var packagePath = path_1.join(window.coderoad.dir, 'package.json');
1010
return new Promise(function (resolve, reject) {
1111
editor_1.open(packagePath);
1212
setTimeout(function () {

lib/reducers/editor-actions/action-helpers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ function getCommand(actionString) {
1111
}
1212
exports.getCommand = getCommand;
1313
function getParams(actionString) {
14+
var parser = new parser_1.ParseParams;
1415
var command = getCommand(actionString);
1516
var params = actionString.substring(command.length + 1, actionString.length - 1);
1617
if (!params.length) {
1718
console.error('Error loading editor action params ', actionString);
1819
return null;
1920
}
20-
var paramsList = parser_1.parseParams.getParams(params);
21+
var paramsList = parser.getParams(params);
2122
return paramsList;
2223
}
2324
exports.getParams = getParams;

lib/reducers/editor-actions/actions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var Editor = require('../../atom/editor');
2+
var editor_1 = require('../../atom/editor');
33
var actions_1 = require('../../atom/actions');
44
var action_helpers_1 = require('./action-helpers');
55
var Type = {
@@ -18,7 +18,7 @@ function editorActions(actionString) {
1818
var file = obj.param;
1919
var options = obj.options;
2020
if (params.length === 1) {
21-
Editor.open(file, options);
21+
editor_1.open(file, options);
2222
setTimeout(function () {
2323
resolve();
2424
}, 100);
@@ -28,7 +28,7 @@ function editorActions(actionString) {
2828
if (params.length === 1) {
2929
var content_1 = params[0];
3030
setTimeout(function () {
31-
Editor.set(content_1);
31+
editor_1.set(content_1);
3232
resolve(true);
3333
});
3434
}
@@ -37,7 +37,7 @@ function editorActions(actionString) {
3737
if (params.length === 1) {
3838
var content_2 = params[0];
3939
setTimeout(function () {
40-
Editor.insert(content_2, {});
40+
editor_1.insert(content_2, {});
4141
resolve(true);
4242
});
4343
}

lib/reducers/editor-actions/editor-actions.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"use strict";
2-
var Type = require('../../actions/actionTypes');
2+
var actionTypes_1 = require('../../actions/actionTypes');
33
var times = require('lodash').times;
44
var actions_1 = require('./actions');
55
function handleEditorActions(actionArray) {
@@ -12,12 +12,12 @@ var actions;
1212
function editorActionsReducer(editorActions, action) {
1313
if (editorActions === void 0) { editorActions = []; }
1414
switch (action.type) {
15-
case Type.SET_PAGE:
15+
case actionTypes_1.SET_PAGE:
1616
actions = action.payload.actions;
1717
currentTaskPosition = 0;
1818
handleEditorActions(actions.shift());
1919
return actions;
20-
case Type.TEST_RESULT:
20+
case actionTypes_1.TEST_RESULT:
2121
actions = action.payload.actions;
2222
var nextTaskPosition = action.payload.result.taskPosition;
2323
if (nextTaskPosition > currentTaskPosition) {

lib/reducers/editor-actions/parser.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
"use strict";
2-
exports.parseParams = {
3-
trim: function (text) {
2+
var ParseParams = (function () {
3+
function ParseParams() {
4+
this.reset();
5+
}
6+
ParseParams.prototype.trim = function (text) {
47
text = text.trim();
58
var firstBracket = text.charAt(0).match(/["']/);
69
if (firstBracket && !!text.charAt(text.length - 1).match(firstBracket[0])) {
710
text = text.substring(1, text.length - 1);
811
}
912
return text;
10-
},
11-
addBreak: function (char, index) {
13+
};
14+
ParseParams.prototype.addBreak = function (char, index) {
1215
switch (char) {
1316
case '(':
1417
this.round += 1;
@@ -39,19 +42,22 @@ exports.parseParams = {
3942
else {
4043
this.current += char;
4144
}
42-
},
43-
getParams: function (text) {
45+
};
46+
ParseParams.prototype.getParams = function (text) {
4447
this.reset();
4548
for (var i = 0; i < text.length; i++) {
4649
this.addBreak(text[i], i);
4750
}
4851
return this.params.concat(this.trim(this.current));
49-
},
50-
reset: function () {
52+
};
53+
ParseParams.prototype.reset = function () {
5154
this.round = 0;
5255
this.square = 0;
5356
this.curly = 0;
5457
this.current = '';
5558
this.params = [];
56-
}
57-
};
59+
};
60+
return ParseParams;
61+
}());
62+
exports.ParseParams = ParseParams;
63+
;

lib/reducers/route/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var actionTypes_1 = require('../../actions/actionTypes');
3-
var defaultRoute = 'tutorials';
3+
var defaultRoute = 'start';
44
function routeReducer(route, action) {
55
if (route === void 0) { route = defaultRoute; }
66
switch (action.type) {

lib/reducers/tutorials/update-tutorial.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22
var command_line_1 = require('../../services/command-line');
33
var store_1 = require('../../store/store');
44
var actions_1 = require('../../actions/actions');
5-
function canUpdateTutorial(name, currentVersion) {
6-
return (command_line_1.default('npm', "outdated " + name)
7-
.then(function (res) {
8-
if (res.length > 0) {
9-
var match = res.match(/[0-9\.]+\s+[0-9\.]+\s+([0-9\.]+)/);
10-
if (match.length >= 2) {
11-
return match[1];
12-
}
13-
}
14-
return null;
15-
}));
16-
}
17-
exports.canUpdateTutorial = canUpdateTutorial;
185
function updateTutorial(name) {
196
command_line_1.default('npm', "install --save-dev " + name)
207
.then(function () {

lib/services/exists.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
2-
var fs = require('fs');
2+
var fs_1 = require('fs');
33
function fileExists(pathToFile) {
44
try {
5-
fs.accessSync(pathToFile, fs.F_OK);
5+
fs_1.accessSync(pathToFile, fs_1.F_OK);
66
}
77
catch (e) {
88
if (e) {

lib/services/package.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ var PackageService = (function () {
2525
project: {},
2626
chapters: []
2727
};
28-
this.config = {};
28+
this.packageJson = null;
2929
}
3030
PackageService.prototype.selectPackage = function (packageName) {
3131
var packagePath = path_1.join(window.coderoad.dir, 'node_modules', packageName);
32-
this.config = require(path_1.join(packagePath, 'package.json'));
33-
store_1.store.dispatch(actions_1.setGlobals(this.config));
34-
this.data = require(path_1.join(packagePath, this.config.main));
32+
this.packageJson = require(path_1.join(packagePath, 'package.json'));
33+
store_1.store.dispatch(actions_1.setGlobals(this.packageJson));
34+
this.data = require(path_1.join(packagePath, this.packageJson.main));
3535
this.packageName = packageName;
3636
};
3737
PackageService.prototype.page = function (_a) {
3838
var chapter = _a.chapter, page = _a.page;
3939
return cloneDeep(this.data.chapters[chapter].pages[page]);
4040
};
41-
PackageService.prototype.getConfig = function () {
42-
return this.config;
41+
PackageService.prototype.getPackage = function () {
42+
return this.packageJson;
4343
};
4444
PackageService.prototype.configTaskTests = function (tasks) {
4545
var _this = this;
46-
var config = this.config.config;
46+
var config = this.packageJson.config;
4747
return !tasks ? [] : tasks.map(function (task) {
4848
if (task.tests) {
4949
task.tests = task.tests.map(function (test) {

src/reducers/checks/action-setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from 'path';
1+
import {join} from 'path';
22
import {open, set} from '../../atom/editor';
33
import {openFolder, openTerminal} from '../../atom/actions';
44
import commandLine from '../../services/command-line';
@@ -13,7 +13,7 @@ const packageData = `{
1313
}`;
1414

1515
export function createPackageJson(): Promise<void> {
16-
const packagePath = path.join(window.coderoad.dir, 'package.json');
16+
const packagePath = join(window.coderoad.dir, 'package.json');
1717
return new Promise((resolve, reject) => {
1818
open(packagePath);
1919
setTimeout(function() {

0 commit comments

Comments
 (0)