File tree Expand file tree Collapse file tree 7 files changed +69
-4
lines changed Expand file tree Collapse file tree 7 files changed +69
-4
lines changed Original file line number Diff line number Diff line change 11"use strict" ;
22var types_1 = require ( './types' ) ;
33function tutorialInit ( ) {
4- return { type : types_1 . TUTORIAL_INIT } ;
4+ return function ( dispatch , getState ) {
5+ var name = getState ( ) . packageJson . name ;
6+ dispatch ( { type : types_1 . TUTORIAL_INIT , payload : { name : name } } ) ;
7+ } ;
58}
69exports . tutorialInit = tutorialInit ;
Original file line number Diff line number Diff line change 11"use strict" ;
22var types_1 = require ( './types' ) ;
3- var _tutorial = { } ;
3+ var create_1 = require ( './utils/create' ) ;
4+ var _tutorial = {
5+ title : '' ,
6+ pages : [ {
7+ file : './01/page-01.md' ,
8+ title : 'Page One' ,
9+ description : 'page one description' ,
10+ tasks : [ {
11+ tests : [ './01/01.js' ] ,
12+ description : 'first task' ,
13+ hints : [ 'hint 1' , 'hint 2' ]
14+ } ]
15+ } ]
16+ } ;
417function tutorial ( t , action ) {
518 if ( t === void 0 ) { t = _tutorial ; }
619 switch ( action . type ) {
720 case types_1 . TUTORIAL_INIT :
21+ var name_1 = action . payload . name ;
22+ create_1 . default ( name_1 ) ;
23+ if ( _tutorial . title . length < 1 ) {
24+ t = Object . assign ( { } , t , { title : name_1 } ) ;
25+ }
826 return t ;
927 default :
1028 return t ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+ var atom_plugin_command_line_1 = require ( 'atom-plugin-command-line' ) ;
3+ function createTutorial ( name ) {
4+ return new Promise ( function ( resolve , reject ) {
5+ atom_plugin_command_line_1 . default ( 'coderoad' , "create " + name )
6+ . then ( function ( res ) {
7+ res . match ( / ✓ / g) ? resolve ( ) : reject ( ) ;
8+ } ) ;
9+ } ) ;
10+ }
11+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
12+ exports . default = createTutorial ;
Original file line number Diff line number Diff line change 11import { TUTORIAL_INIT } from './types' ;
22
33export function tutorialInit ( ) {
4- return { type : TUTORIAL_INIT } ;
4+ return function ( dispatch , getState ) {
5+ const name = getState ( ) . packageJson . name ;
6+ dispatch ( { type : TUTORIAL_INIT , payload : { name } } ) ;
7+ } ;
58}
Original file line number Diff line number Diff line change 11import { TUTORIAL_INIT } from './types' ;
2+ import createTutorial from './utils/create' ;
23
3- const _tutorial = { } ;
4+ const _tutorial = {
5+ title : '' ,
6+ pages : [ {
7+ file : './01/page-01.md' ,
8+ title : 'Page One' ,
9+ description : 'page one description' ,
10+ tasks : [ {
11+ tests : [ './01/01.js' ] ,
12+ description : 'first task' ,
13+ hints : [ 'hint 1' , 'hint 2' ]
14+ } ]
15+ } ]
16+ } ;
417
518export default function tutorial ( t = _tutorial , action : Action ) {
619 switch ( action . type ) {
720 case TUTORIAL_INIT :
21+ const { name} = action . payload ;
22+ createTutorial ( name ) ;
23+ if ( _tutorial . title . length < 1 ) {
24+ t = Object . assign ( { } , t , { title : name } ) ;
25+ }
826 return t ;
927 default :
1028 return t ;
Original file line number Diff line number Diff line change 1+ import commandLine from 'atom-plugin-command-line' ;
2+
3+ export default function createTutorial ( name : string ) {
4+ return new Promise ( ( resolve , reject ) => {
5+ commandLine ( 'coderoad' , `create ${ name } ` )
6+ . then ( ( res : string ) => {
7+ res . match ( / ✓ / g) ? resolve ( ) : reject ( ) ;
8+ } ) ;
9+ } ) ;
10+ }
Original file line number Diff line number Diff line change 5353 " src/modules/tutorial/index.ts" ,
5454 " src/modules/tutorial/reducer.ts" ,
5555 " src/modules/tutorial/types.ts" ,
56+ " src/modules/tutorial/utils/create.ts" ,
5657 " src/reducers.ts" ,
5758 " src/store.ts" ,
5859 " src/subscriptions.ts" ,
You can’t perform that action at this time.
0 commit comments