File tree 6 files changed +28
-9
lines changed
lib/modules/page/task-actions
src/modules/page/task-actions
6 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ var Type = {
10
10
} ;
11
11
function handleActionString ( actionString ) {
12
12
return new Promise ( function ( resolve , reject ) {
13
+ if ( typeof actionString !== 'string' ) {
14
+ reject ( actionString ) ;
15
+ }
13
16
var command = parser_1 . getCommand ( actionString ) ;
14
17
var params = parser_1 . getParams ( actionString ) ;
15
18
switch ( command ) {
@@ -45,7 +48,7 @@ function handleActionString(actionString) {
45
48
reject ( false ) ;
46
49
}
47
50
} ) . catch ( function ( err ) {
48
- console . error ( 'Error with editor ' , err ) ;
51
+ console . error ( 'Error handling action string ' , err ) ;
49
52
} ) ;
50
53
}
51
54
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ function handleTaskActions(actions) {
4
4
var next = actions . shift ( ) ;
5
5
if ( next && next . length ) {
6
6
next . reduce ( function ( total , curr ) {
7
+ if ( ! curr || ! curr . length ) {
8
+ return total ;
9
+ }
7
10
return total . then ( function ( ) { return handle_action_string_1 . default ( curr ) ; } ) ;
8
11
} , Promise . resolve ( ) ) ;
9
12
}
Original file line number Diff line number Diff line change @@ -4,19 +4,22 @@ function getCommand(actionString) {
4
4
var command = actionString . substring ( 0 , actionString . indexOf ( '(' ) ) ;
5
5
if ( ! command . length ) {
6
6
console . log ( 'Error loading editor action command ' , actionString ) ;
7
+ return '' ;
7
8
}
8
- else {
9
- return command ;
10
- }
9
+ return command ;
11
10
}
12
11
exports . getCommand = getCommand ;
13
12
function getParams ( actionString ) {
13
+ if ( typeof actionString !== 'string' ) {
14
+ console . log ( 'Error in tutorial with action command. Expected a string but received ' , actionString ) ;
15
+ return [ ] ;
16
+ }
14
17
var parser = new parse_params_1 . default ( ) ;
15
18
var command = getCommand ( actionString ) ;
16
19
var params = actionString . substring ( command . length + 1 , actionString . length - 1 ) ;
17
20
if ( ! params . length ) {
18
21
console . error ( 'Error loading editor action params ' , actionString ) ;
19
- return null ;
22
+ return [ ] ;
20
23
}
21
24
var paramsList = parser . getParams ( params ) ;
22
25
return paramsList ;
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ export default function handleActionString(
14
14
actionString : string
15
15
) : Promise < void > {
16
16
return new Promise ( ( resolve , reject ) => {
17
+ if ( typeof actionString !== 'string' ) {
18
+ reject ( actionString ) ;
19
+ }
17
20
const command : string = getCommand ( actionString ) ;
18
21
const params : string [ ] = getParams ( actionString ) ;
19
22
@@ -63,6 +66,6 @@ export default function handleActionString(
63
66
reject ( false ) ;
64
67
}
65
68
} ) . catch ( ( err ) => {
66
- console . error ( 'Error with editor ' , err ) ;
69
+ console . error ( 'Error handling action string ' , err ) ;
67
70
} ) ;
68
71
}
Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ export default function handleTaskActions(actions: string[][]): void {
5
5
if ( next && next . length ) {
6
6
// resolve promises in order
7
7
next . reduce ( ( total : Promise < any > , curr : string ) => {
8
+ if ( ! curr || ! curr . length ) {
9
+ return total ;
10
+ }
8
11
return total . then ( ( ) => handleActionString ( curr ) ) ;
9
12
} , Promise . resolve ( ) ) ;
10
13
}
Original file line number Diff line number Diff line change @@ -5,19 +5,23 @@ export function getCommand(actionString: string): string {
5
5
let command = actionString . substring ( 0 , actionString . indexOf ( '(' ) ) ;
6
6
if ( ! command . length ) {
7
7
console . log ( 'Error loading editor action command ' , actionString ) ;
8
- } else {
9
- return command ;
8
+ return '' ;
10
9
}
10
+ return command ;
11
11
}
12
12
13
13
export function getParams ( actionString : string ) : string [ ] {
14
+ if ( typeof actionString !== 'string' ) {
15
+ console . log ( 'Error in tutorial with action command. Expected a string but received ' , actionString ) ;
16
+ return [ ] ;
17
+ }
14
18
// content in brackets, split by comma
15
19
let parser = new ParseParams ( ) ;
16
20
let command = getCommand ( actionString ) ;
17
21
let params = actionString . substring ( command . length + 1 , actionString . length - 1 ) ; // trim brackets
18
22
if ( ! params . length ) {
19
23
console . error ( 'Error loading editor action params ' , actionString ) ;
20
- return null ;
24
+ return [ ] ;
21
25
}
22
26
let paramsList : string [ ] = parser . getParams ( params ) ;
23
27
return paramsList ;
You can’t perform that action at this time.
0 commit comments