Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit683b0f5

Browse files
committed
fix task run styles, lower timeout values
1 parentc93d997 commit683b0f5

File tree

26 files changed

+66
-90
lines changed

26 files changed

+66
-90
lines changed

‎lib/atom/actions/file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
varfs_1=require('fs');
33
varexists_1=require('../../services/exists');
44
vareditor_1=require('./editor');
5+
varopenTimeout=200;
56
functionopenFolder(){
67
atom.open();
78
}
@@ -19,7 +20,7 @@ function open(filePath, options) {
1920
atom.workspace.open(filePath,options);
2021
setTimeout(function(){
2122
resolve();
22-
},200);
23+
},openTimeout);
2324
});
2425
}
2526
exports.open=open;

‎lib/atom/actions/terminal.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
"use strict";
22
functionopenTerminal(){
3-
if(atom.packages.isPackageActive('terminal-plus')){
4-
if(!document.getElementsByClassName('xterm')[0]){
5-
atom.commands.dispatch(document.getElementsByTagName('atom-workspace')[0],'terminal-plus:toggle');
6-
}
7-
returntrue;
8-
}
93
returnfalse;
104
}
115
exports.openTerminal=openTerminal;

‎lib/atom/actions/write.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ function set(text) {
1717
exports.set=set;
1818
functioninsert(text,options){
1919
if(options===void0){options={};}
20-
options=Object.assign(options,{
21-
autoIndent:true,
22-
});
2320
returnwrite('insert',text,options);
2421
}
2522
exports.insert=insert;

‎lib/components/Page/Task/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ function getStatus(index, taskPosition, testRun) {
2727
exports.Task=function(_a){
2828
vartask=_a.task,taskPosition=_a.taskPosition,index=_a.index,testRun=_a.testRun;
2929
varbackgroundColor=getStatus(index,taskPosition,testRun);
30-
varcurrentTask=taskPosition===index;
31-
return(React.createElement(List_1.ListItem,{key:index,style:Object.assign({},styles,{backgroundColor:backgroundColor})},taskCheckbox_1.taskCheckbox(task,testRun),React.createElement("span",{style:indexStyles},index+1,"."),React.createElement("div",{style:descriptionStyles},React.createElement(index_1.Markdown,null,task.description))));
30+
varisCurrentTask=taskPosition===index;
31+
return(React.createElement(List_1.ListItem,{key:index,style:Object.assign({},styles,{backgroundColor:backgroundColor})},taskCheckbox_1.taskCheckbox(isCurrentTask,testRun),React.createElement("span",{style:indexStyles},index+1,"."),React.createElement("div",{style:descriptionStyles},React.createElement(index_1.Markdown,null,task.description))));
3232
};

‎lib/components/Page/Task/taskCheckbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ var styles = {
66
position:'absolute',
77
top:'15px'
88
};
9-
functiontaskCheckbox(currentTask,testRun){
10-
if(!currentTask||!testRun){
9+
functiontaskCheckbox(isCurrentTask,testRun){
10+
if(!isCurrentTask||!testRun){
1111
returnnull;
1212
}
1313
return(React.createElement("span",{style:styles},React.createElement(indeterminate_check_box_1.default,{color:colors_1.orange500})));

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ function editorActions(actionString) {
1313
varparams=action_helpers_1.getParams(actionString);
1414
switch(command){
1515
caseType.OPEN:
16-
varobj=action_helpers_1.getOptions(params[0]);
17-
varfile=obj.param;
18-
varoptions=obj.options;
16+
var_a=action_helpers_1.getOptions(params[0]),param=_a.param,options=_a.options;
1917
if(params.length===1){
20-
editor_1.open(file,options);
18+
editor_1.open(param,options);
2119
setTimeout(function(){
2220
resolve();
2321
},100);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function editorActionsReducer(editorActions, action) {
1818
handleEditorActions(actions.shift());
1919
returnactions;
2020
case_types_1.TEST_RESULT:
21-
actions=action.payload.actions;
21+
actions=action.payload.actions||[];
2222
varnextTaskPosition=action.payload.result.taskPosition;
2323
if(nextTaskPosition>currentTaskPosition){
2424
for(vari=0;i<nextTaskPosition-currentTaskPosition;i++){

‎lib/reducers/progress/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function progressReducer(progress, action) {
2727
})
2828
};
2929
case_types_1.COMPLETE_PAGE:
30-
varposition=action.payload.position;
31-
progress.chapters[position.chapter].pages[position.page]=true;
30+
var_a=action.payload.position,chapter=_a.chapter,page=_a.page;
31+
progress.chapters[chapter].pages[page]=true;
3232
local_storage_1.saveToLocalStorage(progress);
3333
returnprogress;
3434
case_types_1.COMPLETE_CHAPTER:

‎lib/reducers/route/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ function routeReducer(route, action) {
55
if(route===void0){route=_route;}
66
switch(action.type){
77
case_types_1.ROUTE_SET:
8-
varnext=action.payload.route;
98
returnaction.payload.route;
109
default:
1110
returnroute;

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ function taskTestsReducer(taskTests, action) {
66
if(taskTests===void0){taskTests='';}
77
switch(action.type){
88
case_types_1.TESTS_LOAD:
9-
vartasks=store_1.default.getState().tasks;
10-
vartests=[].concat.apply([],tasks.map(function(task){returntask.tests||[];}));
11-
varoutput_1='';
12-
tests.forEach(function(file){
9+
return[].concat.apply([],store_1.default.getState().tasks.map(function(task){returntask.tests||[];})).reduce(function(output,file){
1310
try{
14-
vardata=fs_1.readFileSync(file,'utf8');
15-
output_1+=data+'\n';
11+
output+=fs_1.readFileSync(file,'utf8')+'\n';
1612
}
1713
catch(e){
1814
console.log('Error reading test file',e);
1915
}
20-
});
21-
returnoutput_1;
16+
returnoutput;
17+
},'');
2218
default:
2319
returntaskTests;
2420
}

‎lib/reducers/tasks/config-task-tests.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ function configTestString(config, name, testPath) {
1111
testPath=path_1.join(tutorial.config.dir,testPath);
1212
}
1313
else{
14-
vardir=store_1.default.getState().dir;
15-
testPath=path_1.join(dir,'node_modules',name,testPath);
14+
testPath=path_1.join(store_1.default.getState().dir,'node_modules',name,testPath);
1615
}
1716
if(tutorial.config.testSuffix){
1817
testPath+=tutorial.config.testSuffix;

‎lib/reducers/test-run/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22
var_types_1=require('../../actions/_types');
33
varrun_1=require('./run');
4-
varpageTimeout=2000;
4+
varpageTimeout=800;
55
varprevious=newDate().getTime();
66
functionrunTestReducer(testRun,action){
77
if(testRun===void0){testRun=false;}

‎src/atom/actions/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function getEditor(): Promise<AtomCore.IEditor> {
44
leteditor=atom.workspace.getActiveTextEditor();
55
while(!editor){
66
getEditorCount+=1;
7-
setTimeout(function(){
7+
setTimeout(()=>{
88
editor=atom.workspace.getActiveTextEditor();
99
},10);
1010
if(getEditorCount>1000){

‎src/atom/actions/file.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import {unlink} from 'fs';
22
import{fileExists}from'../../services/exists';
33
import{getEditor}from'./editor';
44

5+
// delay necessary since opening a file is slow
6+
constopenTimeout=200;
7+
58
exportfunctionopenFolder():void{
69
atom.open();
710
}
@@ -19,6 +22,6 @@ export function open(filePath: string, options = {}): Promise<any> {
1922
atom.workspace.open(filePath,options);
2023
setTimeout(()=>{
2124
resolve();
22-
},200);// delay necessary since opening a file is slow
25+
},openTimeout);
2326
});
2427
}

‎src/atom/actions/terminal.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
exportfunctionopenTerminal():boolean{
2-
if(atom.packages.isPackageActive('terminal-plus')){
3-
if(!document.getElementsByClassName('xterm')[0]){
4-
atom.commands.dispatch(
5-
document.getElementsByTagName('atom-workspace')[0],'terminal-plus:toggle'
6-
);
7-
}
8-
returntrue;
9-
}
2+
// if (atom.packages.isPackageActive('terminal-plus')) {
3+
// if (!document.getElementsByClassName('xterm')[0]) {
4+
// atom.commands.dispatch(
5+
// document.getElementsByTagName('atom-workspace')[0], 'terminal-plus:toggle'
6+
// );
7+
// }
8+
// return true;
9+
// }
10+
// return false;
1011
returnfalse;
1112
}

‎src/atom/actions/write.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {getEditor} from './editor';
22

33
functionwrite(action:'set'|'insert',text:string,options={}){
44
returngetEditor().then((editor:AtomCore.IEditor)=>{
5-
editor.moveToBottom();
6-
editor[`${action}Text`](text,options);
7-
editor.insertNewline();
8-
editor.moveToBottom();
9-
setCursorPosition(editor);
10-
editor.save();
11-
});
5+
editor.moveToBottom();
6+
editor[`${action}Text`](text,options);
7+
editor.insertNewline();
8+
editor.moveToBottom();
9+
setCursorPosition(editor);
10+
editor.save();
11+
});
1212
}
1313

1414
// Set text, removes any previous content in file
@@ -17,15 +17,12 @@ export function set(text: string) {
1717
}
1818

1919
exportfunctioninsert(text:string,options={}){
20-
options=Object.assign(options,{
21-
autoIndent:true,
22-
});
2320
returnwrite('insert',text,options);
2421
}
2522

2623
constcursor:RegExp=/::>/g;
2724
functionsetCursorPosition(editor:AtomCore.IEditor){
28-
returneditor.scan(cursor,function(scanned){
25+
returneditor.scan(cursor,(scanned)=>{
2926
editor.setCursorScreenPosition(scanned.range.start);
3027
scanned.replace('');
3128
scanned.stop();

‎src/components/Page/Task/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ export const Task: React.StatelessComponent<{
3434
task:CR.Task,taskPosition:number,index:number,testRun:boolean
3535
}>=({task, taskPosition, index, testRun})=>{
3636
constbackgroundColor=getStatus(index,taskPosition,testRun);
37-
constcurrentTask=taskPosition===index;
37+
constisCurrentTask=taskPosition===index;
3838
return(
3939
<ListItem
4040
key={index}
4141
style={Object.assign({},styles,{backgroundColor})}
4242
>
43-
{taskCheckbox(task,testRun)}
43+
{taskCheckbox(isCurrentTask,testRun)}
4444
<spanstyle={indexStyles}>{index+1}.</span>
4545
<divstyle={descriptionStyles}>
4646
<Markdown>{task.description}</Markdown>

‎src/components/Page/Task/taskCheckbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const styles = {
99
top:'15px'
1010
};
1111

12-
exportfunctiontaskCheckbox(currentTask:number,testRun:boolean){
13-
if(!currentTask||!testRun){returnnull;}
12+
exportfunctiontaskCheckbox(isCurrentTask:boolean,testRun:boolean){
13+
if(!isCurrentTask||!testRun){returnnull;}
1414
return(
1515
<spanstyle={styles}>
1616
<IndeterminateCheckBoxcolor={orange500}/>

‎src/reducers/editor-actions/actions.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,18 @@ export function editorActions(actionString: string): Promise<void> {
1414
letparams:string[]=getParams(actionString);
1515
switch(command){
1616
caseType.OPEN:
17-
letobj=getOptions(params[0]);
18-
letfile=obj.param;
19-
letoptions=obj.options;
17+
const{param, options}=getOptions(params[0]);
2018
if(params.length===1){
21-
open(file,options);
22-
setTimeout(function(){
19+
open(param,options);
20+
setTimeout(()=>{
2321
resolve();
2422
},100);
2523
}
2624
break;
2725
caseType.SET:
2826
if(params.length===1){
29-
letcontent=params[0];
30-
31-
setTimeout(function(){
27+
constcontent:string=params[0];
28+
setTimeout(()=>{
3229
set(content);
3330
resolve(true);
3431
});
@@ -37,17 +34,17 @@ export function editorActions(actionString: string): Promise<void> {
3734
caseType.INSERT:
3835
if(params.length===1){
3936
// let obj = getOptions(params[0]);
40-
letcontent:string=params[0];
37+
constcontent:string=params[0];
4138
// let options: object = obj.options;
42-
setTimeout(function(){
39+
setTimeout(()=>{
4340
insert(content,{});
4441
resolve(true);
4542
});
4643
}
4744
break;
4845
caseType.OPEN_CONSOLE:
4946
if(params.length===0){
50-
setTimeout(function(){
47+
setTimeout(()=>{
5148
openDevTools();
5249
resolve(true);
5350
});

‎src/reducers/editor-actions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ export default function editorActionsReducer(
2323
caseTESTS_LOAD:
2424
actions=store.getState().tasks.map(task=>task.actions||[]);
2525
currentTaskPosition=0;
26-
handleEditorActions(actions.shift());
26+
handleEditorActions(actions.shift());// run first action
2727
returnactions;
2828

2929
caseTEST_RESULT:
30-
actions=action.payload.actions;
30+
actions=action.payload.actions||[];
3131
constnextTaskPosition=action.payload.result.taskPosition;
3232
if(nextTaskPosition>currentTaskPosition){
3333
// run actions for each task position passed
3434
for(leti=0;i<nextTaskPosition-currentTaskPosition;i++){
35-
handleEditorActions(actions.shift());
35+
handleEditorActions(actions.shift());// run first action
3636
}
3737
currentTaskPosition=nextTaskPosition;
3838
}

‎src/reducers/progress/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export default function progressReducer(
3131
})
3232
};
3333
caseCOMPLETE_PAGE:
34-
constposition=action.payload.position;
35-
progress.chapters[position.chapter].pages[position.page]=true;
34+
const{chapter, page}=action.payload.position;
35+
progress.chapters[chapter].pages[page]=true;
3636
saveToLocalStorage(progress);
3737
returnprogress;
3838
caseCOMPLETE_CHAPTER:

‎src/reducers/route/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default function routeReducer(
88
):string{
99
switch(action.type){
1010
caseROUTE_SET:
11-
constnext=action.payload.route;
1211
returnaction.payload.route;
1312
default:
1413
returnroute;

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@ export default function taskTestsReducer(
77
):string{
88
switch(action.type){
99
caseTESTS_LOAD:
10-
consttasks=store.getState().tasks;
11-
lettests:string[]=[].concat.apply([],tasks.map(
12-
task=>task.tests||[])
13-
);
14-
letoutput='';
15-
tests.forEach(function(file:string):void{
10+
return[].concat.apply([],store.getState().tasks.map(
11+
task=>task.tests||[])
12+
).reduce((output:string,file:string):string=>{
1613
try{
17-
letdata=readFileSync(file,'utf8');
18-
output+=data+'\n';
14+
output+=readFileSync(file,'utf8')+'\n';
1915
}catch(e){
2016
console.log('Error reading test file',e);
2117
}
22-
});
23-
returnoutput;
18+
returnoutput;
19+
},'');
2420
default:
2521
returntaskTests;
2622
}

‎src/reducers/tasks/config-task-tests.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ function configTestString(config: Tutorial.Config, name: string, testPath: strin
1212
if(tutorial&&tutorial.config.dir){
1313
testPath=join(tutorial.config.dir,testPath);
1414
}else{
15-
constdir=store.getState().dir;
16-
testPath=join(dir,'node_modules',name,testPath);
15+
testPath=join(store.getState().dir,'node_modules',name,testPath);
1716
}
1817

1918
if(tutorial.config.testSuffix){

‎src/reducers/test-run/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
}from'../../actions/_types';
44
import{runTaskTests}from'./run';
55

6-
constpageTimeout=2000;
6+
constpageTimeout=800;
77

88
letprevious:number=newDate().getTime();
99

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp