7
7
8
8
import * as gulp from 'gulp' ;
9
9
import { QuestionnaireSubscriber } from '../config-wizard' ;
10
+ import Logger , { ILogger } from '../util/logger' ;
10
11
import { hasNested , limitFn } from '../util/utility-functions' ;
11
12
12
13
@@ -21,9 +22,12 @@ export interface TaskSubscriber {
21
22
export interface TaskManager {
22
23
run ( hook : string ) : Promise < boolean > ;
23
24
getSubscribers ( ) : TaskSubscriber ;
25
+ /* test:start */
26
+ subscribe ?( task : string , hook : string ) : boolean ;
24
27
hasTasks ?( hook : string ) : boolean ;
25
28
getTasks ?( ) : Tasks ;
26
29
getHooks ?( ) : string [ ] ;
30
+ /* test:end */
27
31
}
28
32
29
33
export interface TaskManagerOptions {
@@ -38,6 +42,7 @@ export interface TaskManagerOptions {
38
42
function TaskManager ( options ?: TaskManagerOptions ) : TaskManager {
39
43
let hooks : string [ ] = [ ] ;
40
44
const tasks : Tasks = { } ;
45
+ const logger : ILogger = Logger ( 'frontvue' ) ( 'TaskManager' ) ;
41
46
42
47
if ( options && hasNested ( options , 'hooks' ) ) {
43
48
hooks = [ ...hooks , ...options . hooks ] ;
@@ -57,8 +62,7 @@ function TaskManager(options?: TaskManagerOptions): TaskManager {
57
62
return resolve ( true ) ;
58
63
}
59
64
60
- // TODO: Log out error message using custom logger
61
- console . log ( `>>> hook ${ hook } doesn't exist or doesn't have any tasks` ) ;
65
+ logger . warn ( `<${ hook } > hook doesn't exist or has no tasks` ) ;
62
66
return resolve ( false ) ;
63
67
} ) ;
64
68
}
@@ -94,6 +98,11 @@ function TaskManager(options?: TaskManagerOptions): TaskManager {
94
98
}
95
99
96
100
101
+ /**
102
+ * Subscribe a task to a hook
103
+ * @param task Task name
104
+ * @param hook Hook name
105
+ */
97
106
function subscribe ( task : string , hook : string ) : boolean {
98
107
// Create new array for hook, if not available
99
108
if ( ! hasNested ( tasks , hook ) ) {
@@ -149,6 +158,7 @@ function TaskManager(options?: TaskManagerOptions): TaskManager {
149
158
getHooks,
150
159
getTasks,
151
160
hasTasks,
161
+ subscribe,
152
162
} ;
153
163
/* test:end */
154
164
0 commit comments