Skip to content

Commit ee390ea

Browse files
committed
fix file open issue by deleting file first
1 parent e51d770 commit ee390ea

File tree

16 files changed

+115
-36
lines changed

16 files changed

+115
-36
lines changed

lib/atom/editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use strict";
22
var _base_1 = require('../_base');
3+
var fs = require('fs');
4+
var exists_1 = require('../services/exists');
35
var Action = require('../actions/actions');
46
function setAtomGlobals() {
57
if (atom.project.rootDirectories.length > 0) {
@@ -39,6 +41,9 @@ function getEditor() {
3941
}
4042
exports.getEditor = getEditor;
4143
function open(filePath, options) {
44+
if (exists_1.fileExists(filePath)) {
45+
fs.unlink(filePath);
46+
}
4247
atom.workspace.open(filePath, options);
4348
return true;
4449
}

lib/components/account/account.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ var default_1 = (function (_super) {
1111
_super.apply(this, arguments);
1212
}
1313
default_1.prototype.render = function () {
14-
return (React.createElement("section", {className: 'cr-account'}, React.createElement("h3", null, "Account")));
14+
return (React.createElement("section", {className: 'cr-account'},
15+
React.createElement("h3", null, "Account")
16+
));
1517
};
1618
return default_1;
1719
}(React.Component));

lib/components/app/app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ var default_1 = (function (_super) {
3030
};
3131
default_1.prototype.render = function () {
3232
var state = this.props.state;
33-
return (React.createElement("section", {className: 'cr'}, React.createElement(_components_1.Menu, {route: state.route, position: state.position}), React.createElement(_components_1.Router, {state: state}), React.createElement(_components_1.Alert, {alert: state.alert})));
33+
return (React.createElement("section", {className: 'cr'},
34+
React.createElement(_components_1.Menu, {route: state.route, position: state.position}),
35+
React.createElement(_components_1.Router, {state: state}),
36+
React.createElement(_components_1.Alert, {alert: state.alert})));
3437
};
3538
default_1.childContextTypes = {
3639
muiTheme: React.PropTypes.object,

lib/components/menu/menu.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ var default_1 = (function (_super) {
3939
default_1.prototype.menuOptions = function () {
4040
switch (this.props.route) {
4141
case 'page':
42-
return (React.createElement("div", null, React.createElement(material_ui_1.MenuItem, {primaryText: 'progress', onClick: this.props.routeToProgress}), React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onClick: this.props.routeToProjects})));
42+
return (React.createElement("div", null,
43+
React.createElement(material_ui_1.MenuItem, {primaryText: 'progress', onClick: this.props.routeToProgress}),
44+
React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onClick: this.props.routeToProjects})));
4345
case 'progress':
4446
return React.createElement(material_ui_1.MenuItem, {primaryText: 'projects', onClick: this.props.routeToProjects});
4547
default: return null;
@@ -49,7 +51,17 @@ var default_1 = (function (_super) {
4951
render_1.togglePanel();
5052
};
5153
default_1.prototype.render = function () {
52-
return (React.createElement(material_ui_1.AppBar, {title: 'CodeRoad', className: 'cr-menu-bar', iconElementLeft: React.createElement(material_ui_1.IconButton, {onClick: this.closePanel}, React.createElement(NavigationClose, null)), iconElementRight: React.createElement(material_ui_1.IconMenu, {iconButtonElement: React.createElement(material_ui_1.IconButton, null, React.createElement(MoreVertIcon, null)), targetOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'top' }}, this.menuOptions(), window.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, null, React.createElement("a", {href: window.coderoad.issuesPath}, "post issue")) : null, React.createElement(material_ui_1.Divider, null), React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onClick: this.props.quit}))}));
54+
return (React.createElement(material_ui_1.AppBar, {title: 'CodeRoad', className: 'cr-menu-bar', iconElementLeft: React.createElement(material_ui_1.IconButton, {onClick: this.closePanel},
55+
React.createElement(NavigationClose, null)
56+
), iconElementRight: React.createElement(material_ui_1.IconMenu, {iconButtonElement: React.createElement(material_ui_1.IconButton, null,
57+
React.createElement(MoreVertIcon, null)
58+
), targetOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'top' }},
59+
this.menuOptions(),
60+
window.coderoad.issuesPath ? React.createElement(material_ui_1.MenuItem, null,
61+
React.createElement("a", {href: window.coderoad.issuesPath}, "post issue")
62+
) : null,
63+
React.createElement(material_ui_1.Divider, null),
64+
React.createElement(material_ui_1.MenuItem, {primaryText: 'quit', onClick: this.props.quit}))}));
5365
};
5466
default_1 = __decorate([
5567
react_redux_1.connect(null, function (dispatch) {

lib/components/page/chapter.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ var _components_1 = require('../_components');
44
Object.defineProperty(exports, "__esModule", { value: true });
55
exports.default = function (_a) {
66
var chapter = _a.chapter;
7-
return (React.createElement("section", {className: 'cr-chapter'}, React.createElement(_components_1.MarkdownText, {text: chapter.title})));
7+
return (React.createElement("section", {className: 'cr-chapter'},
8+
React.createElement(_components_1.MarkdownText, {text: chapter.title})
9+
));
810
};

lib/components/page/content.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ var _components_1 = require('../_components');
44
var material_ui_1 = require('material-ui');
55
function default_1(_a) {
66
var page = _a.page;
7-
return (React.createElement(material_ui_1.Card, null, React.createElement(material_ui_1.CardHeader, {title: page.title}), React.createElement(material_ui_1.CardText, null, React.createElement(_components_1.MarkdownText, {text: page.description}))));
7+
return (React.createElement(material_ui_1.Card, null,
8+
React.createElement(material_ui_1.CardHeader, {title: page.title}),
9+
React.createElement(material_ui_1.CardText, null,
10+
React.createElement(_components_1.MarkdownText, {text: page.description})
11+
)));
812
}
913
Object.defineProperty(exports, "__esModule", { value: true });
1014
exports.default = default_1;

lib/components/page/edit.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
exports.default = function (editPath) {
77
if (editPath && window.coderoad.edit) {
88
var repoPath = path.join(window.coderoad.repo, 'edit', 'master', editPath);
9-
return React.createElement("a", {href: repoPath}, React.createElement(Edit, {style: { position: 'absolute', top: '10px', right: '10px' }}));
9+
return React.createElement("a", {href: repoPath},
10+
React.createElement(Edit, {style: { position: 'absolute', top: '10px', right: '10px' }})
11+
);
1012
}
1113
};

lib/components/page/hint.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@ function hintsShown(task, hintPosition) {
1010
}
1111
exports.TaskHint = function (_a) {
1212
var hint = _a.hint, index = _a.index;
13-
return (React.createElement(material_ui_1.ListItem, {className: 'cr-task-hint', key: 'hint' + index}, React.createElement("div", {class: 'cr-task-hint-box'}, React.createElement("span", {className: 'cr-task-hint-index'}, index + 1, "."), React.createElement("div", {className: 'cr-task-hint-description'}, React.createElement(_components_1.MarkdownText, {text: hint})))));
13+
return (React.createElement(material_ui_1.ListItem, {className: 'cr-task-hint', key: 'hint' + index},
14+
React.createElement("div", {class: 'cr-task-hint-box'},
15+
React.createElement("span", {className: 'cr-task-hint-index'},
16+
index + 1,
17+
"."),
18+
React.createElement("div", {className: 'cr-task-hint-description'},
19+
React.createElement(_components_1.MarkdownText, {text: hint})
20+
))
21+
));
1422
};
1523
exports.TaskHints = function (_a) {
1624
var task = _a.task, hintPosition = _a.hintPosition;

lib/components/page/page-complete.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var _components_1 = require('../_components');
55
exports.PageCompleteMessage = function (_a) {
66
var page = _a.page;
77
return (React.createElement("div", {className: 'cr-task-onComplete-description'}, page.completed && page.onPageComplete ?
8-
React.createElement(material_ui_1.ListItem, {className: 'cr-task-onComplete', key: 'page-complete'}, React.createElement(_components_1.MarkdownText, {text: page.onPageComplete}))
8+
React.createElement(material_ui_1.ListItem, {className: 'cr-task-onComplete', key: 'page-complete'},
9+
React.createElement(_components_1.MarkdownText, {text: page.onPageComplete})
10+
)
911
: null));
1012
};

lib/components/page/page.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,15 @@ var default_1 = (function (_super) {
4949
var _a = this.props, page = _a.page, taskPosition = _a.taskPosition, hintPosition = _a.hintPosition, tasks = _a.tasks, runTests = _a.runTests;
5050
var currentTask = taskPosition <= tasks.length ? tasks[taskPosition] : null;
5151
var allComplete = taskPosition >= tasks.length;
52-
return (React.createElement(material_ui_2.Paper, {style: style, zDepth: 1, className: 'cr-page'}, React.createElement(content_1.default, {page: page}), React.createElement(material_ui_1.Divider, null), React.createElement(material_ui_1.List, {subheader: 'Tasks', className: 'cr-page-list', ref: 'tasks'}, React.createElement(task_1.Tasks, {tasks: tasks, taskPosition: taskPosition, runTests: runTests}), React.createElement(hint_1.TaskHints, {task: currentTask, hintPosition: hintPosition}), React.createElement(page_complete_1.PageCompleteMessage, {page: page}), React.createElement("div", {ref: 'listEnd'})), React.createElement(toolbar_1.default, {tasks: tasks, taskPosition: taskPosition, hintPosition: hintPosition})));
52+
return (React.createElement(material_ui_2.Paper, {style: style, zDepth: 1, className: 'cr-page'},
53+
React.createElement(content_1.default, {page: page}),
54+
React.createElement(material_ui_1.Divider, null),
55+
React.createElement(material_ui_1.List, {subheader: 'Tasks', className: 'cr-page-list', ref: 'tasks'},
56+
React.createElement(task_1.Tasks, {tasks: tasks, taskPosition: taskPosition, runTests: runTests}),
57+
React.createElement(hint_1.TaskHints, {task: currentTask, hintPosition: hintPosition}),
58+
React.createElement(page_complete_1.PageCompleteMessage, {page: page}),
59+
React.createElement("div", {ref: 'listEnd'})),
60+
React.createElement(toolbar_1.default, {tasks: tasks, taskPosition: taskPosition, hintPosition: hintPosition})));
5361
};
5462
default_1 = __decorate([
5563
react_redux_1.connect(null, function (dispatch, state) {

lib/components/page/task.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ var TaskCheckbox = function (_a) {
2626
};
2727
var TaskIndex = function (_a) {
2828
var index = _a.index;
29-
return (React.createElement("span", {className: 'cr-task-index'}, index + 1, "."));
29+
return (React.createElement("span", {className: 'cr-task-index'},
30+
index + 1,
31+
"."));
3032
};
3133
var TaskContent = function (_a) {
3234
var task = _a.task;
33-
return (React.createElement("div", {className: 'cr-task-description'}, React.createElement(_components_1.MarkdownText, {text: task.description})));
35+
return (React.createElement("div", {className: 'cr-task-description'},
36+
React.createElement(_components_1.MarkdownText, {text: task.description})
37+
));
3438
};
3539
exports.Task = function (_a) {
3640
var task = _a.task, taskPosition = _a.taskPosition, index = _a.index, runTests = _a.runTests;
@@ -41,7 +45,10 @@ exports.Task = function (_a) {
4145
else if (index === taskPosition) {
4246
taskClass += 'isCurrentTask';
4347
}
44-
return (React.createElement(material_ui_1.ListItem, {key: index, className: taskClass}, React.createElement(TaskCheckbox, {index: index, taskPosition: taskPosition, runTests: runTests}), React.createElement(TaskIndex, {index: index}), React.createElement(TaskContent, {task: task})));
48+
return (React.createElement(material_ui_1.ListItem, {key: index, className: taskClass},
49+
React.createElement(TaskCheckbox, {index: index, taskPosition: taskPosition, runTests: runTests}),
50+
React.createElement(TaskIndex, {index: index}),
51+
React.createElement(TaskContent, {task: task})));
4552
};
4653
exports.Tasks = function (_a) {
4754
var tasks = _a.tasks, taskPosition = _a.taskPosition, runTests = _a.runTests;

lib/components/page/toolbar.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ var default_1 = (function (_super) {
4848
var currentTask = taskPosition <= tasks.length ? tasks[taskPosition] : null;
4949
var progress = taskProgress(taskPosition, tasks.length);
5050
var allComplete = taskPosition >= tasks.length;
51-
return (React.createElement("section", {className: 'cr-page-toolbar'}, React.createElement(ProgressBar, {progress: progress}), React.createElement(material_ui_1.Toolbar, null, currentTask && currentTask.hints && currentTask.hints.length ?
52-
React.createElement(material_ui_1.ToolbarGroup, {float: 'left'}, hintPosition <= currentTask.hints.length - 2 ?
53-
React.createElement(material_ui_1.FlatButton, {className: 'cr-task-showHint', icon: React.createElement(InfoOutline, null), onClick: showHint.bind(this, currentTask, hintPosition)})
54-
: React.createElement(material_ui_1.FlatButton, {className: 'cr-task-showHint-disabled', icon: React.createElement(Info, null), disabled: true}))
55-
: null, React.createElement(material_ui_1.ToolbarGroup, {float: 'right'}, allComplete ?
56-
React.createElement(material_ui_1.RaisedButton, {label: 'Continue', primary: true, onClick: callNextPage})
57-
:
58-
React.createElement(material_ui_1.RaisedButton, {label: 'Run', secondary: true, onClick: callRunTests})))));
51+
return (React.createElement("section", {className: 'cr-page-toolbar'},
52+
React.createElement(ProgressBar, {progress: progress}),
53+
React.createElement(material_ui_1.Toolbar, null,
54+
currentTask && currentTask.hints && currentTask.hints.length ?
55+
React.createElement(material_ui_1.ToolbarGroup, {float: 'left'}, hintPosition <= currentTask.hints.length - 2 ?
56+
React.createElement(material_ui_1.FlatButton, {className: 'cr-task-showHint', icon: React.createElement(InfoOutline, null), onClick: showHint.bind(this, currentTask, hintPosition)})
57+
: React.createElement(material_ui_1.FlatButton, {className: 'cr-task-showHint-disabled', icon: React.createElement(Info, null), disabled: true}))
58+
: null,
59+
React.createElement(material_ui_1.ToolbarGroup, {float: 'right'}, allComplete ?
60+
React.createElement(material_ui_1.RaisedButton, {label: 'Continue', primary: true, onClick: callNextPage})
61+
:
62+
React.createElement(material_ui_1.RaisedButton, {label: 'Run', secondary: true, onClick: callRunTests})))));
5963
};
6064
default_1 = __decorate([
6165
react_redux_1.connect(null, function (dispatch, state) {

lib/components/progress/progress.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,16 @@ var style = {
8888
Object.defineProperty(exports, "__esModule", { value: true });
8989
exports.default = function (_a) {
9090
var progress = _a.progress, position = _a.position;
91-
return (React.createElement(material_ui_1.Paper, {style: style, zDepth: 1, className: 'cr-progress'}, React.createElement(material_ui_1.List, {subheader: 'Progress'}, progress.chapters.map(function (chapter, chapterIndex) {
92-
var isActive = chapterIndex === position.chapter;
93-
return React.createElement(material_ui_1.ListItem, {primaryText: (chapterIndex + 1) + ". " + chapter.title, className: classnames({
94-
'chapter': true,
95-
'isActive': isActive
96-
}), secondaryText: chapter.description, secondaryTextLines: chapter.description.length > 35 ? 2 : 1, initiallyOpen: chapterIndex === 0, leftIcon: chapter.completed ? React.createElement(AllCompleted, null) : null, primaryTogglesNestedList: chapterIndex === position.chapter && !chapter.completed, nestedItems: chapter.pages.map(function (page, pageIndex) {
97-
var itemPosition = { chapter: chapterIndex, page: pageIndex };
98-
return React.createElement(ProgressPage, {page: page, itemPosition: itemPosition, position: position});
99-
})});
100-
}))));
91+
return (React.createElement(material_ui_1.Paper, {style: style, zDepth: 1, className: 'cr-progress'},
92+
React.createElement(material_ui_1.List, {subheader: 'Progress'}, progress.chapters.map(function (chapter, chapterIndex) {
93+
var isActive = chapterIndex === position.chapter;
94+
return React.createElement(material_ui_1.ListItem, {primaryText: (chapterIndex + 1) + ". " + chapter.title, className: classnames({
95+
'chapter': true,
96+
'isActive': isActive
97+
}), secondaryText: chapter.description, secondaryTextLines: chapter.description.length > 35 ? 2 : 1, initiallyOpen: chapterIndex === 0, leftIcon: chapter.completed ? React.createElement(AllCompleted, null) : null, primaryTogglesNestedList: chapterIndex === position.chapter && !chapter.completed, nestedItems: chapter.pages.map(function (page, pageIndex) {
98+
var itemPosition = { chapter: chapterIndex, page: pageIndex };
99+
return React.createElement(ProgressPage, {page: page, itemPosition: itemPosition, position: position});
100+
})});
101+
}))
102+
));
101103
};

lib/components/projects/projects.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,21 @@ var Projects = (function (_super) {
3636
};
3737
Projects.prototype.render = function () {
3838
var _this = this;
39-
return (React.createElement(material_ui_1.Paper, {className: 'cr-projects'}, React.createElement("div", {className: 'cr-projects-header'}, React.createElement("span", {className: 'title'}, "CodeRoad"), React.createElement("p", {className: 'tagline'}, "Tutorials in the Editor"), React.createElement("div", {className: 'cr-tutorials'}, React.createElement(material_ui_1.List, {subheader: 'Tutorials'}, window.coderoad.dir ? null : React.createElement(material_ui_1.ListItem, {primaryText: 'Create an Atom Project', secondaryText: 'File > Open > any older'}), this.props.tutorials.length > 0 ?
40-
this.props.tutorials.map(function (tutorial) {
41-
return (React.createElement(material_ui_1.ListItem, {primaryText: _this.trim(tutorial), onClick: _this.props.selectProject.bind(_this, tutorial)}));
42-
}) : React.createElement(material_ui_1.ListItem, {primaryText: 'Try a Demo', secondaryText: 'npm i -s coderoad-functional-school'})), React.createElement("br", null), React.createElement(material_ui_1.RaisedButton, {label: 'Load Tutorials', secondary: true, onClick: this.load.bind(this)})), React.createElement("p", {className: 'notes'}, "Beta"))));
39+
return (React.createElement(material_ui_1.Paper, {className: 'cr-projects'},
40+
React.createElement("div", {className: 'cr-projects-header'},
41+
React.createElement("span", {className: 'title'}, "CodeRoad"),
42+
React.createElement("p", {className: 'tagline'}, "Tutorials in the Editor"),
43+
React.createElement("div", {className: 'cr-tutorials'},
44+
React.createElement(material_ui_1.List, {subheader: 'Tutorials'},
45+
window.coderoad.dir ? null : React.createElement(material_ui_1.ListItem, {primaryText: 'Create an Atom Project', secondaryText: 'File > Open > any older'}),
46+
this.props.tutorials.length > 0 ?
47+
this.props.tutorials.map(function (tutorial) {
48+
return (React.createElement(material_ui_1.ListItem, {primaryText: _this.trim(tutorial), onClick: _this.props.selectProject.bind(_this, tutorial)}));
49+
}) : React.createElement(material_ui_1.ListItem, {primaryText: 'Try a Demo', secondaryText: 'npm i -s coderoad-functional-school'})),
50+
React.createElement("br", null),
51+
React.createElement(material_ui_1.RaisedButton, {label: 'Load Tutorials', secondary: true, onClick: this.load.bind(this)})),
52+
React.createElement("p", {className: 'notes'}, "Beta"))
53+
));
4354
};
4455
Projects = __decorate([
4556
react_redux_1.connect(null, function (dispatch) {

0 commit comments

Comments
 (0)