@@ -53,6 +53,12 @@ const createFSMachine = (
53
53
)
54
54
}
55
55
56
+ const log = expr => ( ctx , action , meta ) => {
57
+ if ( meta . state . matches ( `BOOTSTRAP.BOOTSTRAPPED` ) ) {
58
+ reporter . info ( expr ( ctx , action , meta ) )
59
+ }
60
+ }
61
+
56
62
const fsMachine = Machine (
57
63
{
58
64
id : `fs` ,
@@ -85,9 +91,32 @@ const createFSMachine = (
85
91
} ,
86
92
READY : {
87
93
on : {
88
- CHOKIDAR_ADD : { actions : `createAndProcessNode` } ,
89
- CHOKIDAR_CHANGE : { actions : `createAndProcessNode` } ,
90
- CHOKIDAR_UNLINK : { actions : `deletePathNode` } ,
94
+ CHOKIDAR_ADD : {
95
+ actions : [
96
+ `createAndProcessNode` ,
97
+ log (
98
+ ( _ , { pathType, path } ) => `added ${ pathType } at ${ path } `
99
+ ) ,
100
+ ] ,
101
+ } ,
102
+ CHOKIDAR_CHANGE : {
103
+ actions : [
104
+ `createAndProcessNode` ,
105
+ log (
106
+ ( _ , { pathType, path } ) =>
107
+ `changed ${ pathType } at ${ path } `
108
+ ) ,
109
+ ] ,
110
+ } ,
111
+ CHOKIDAR_UNLINK : {
112
+ actions : [
113
+ `deletePathNode` ,
114
+ log (
115
+ ( _ , { pathType, path } ) =>
116
+ `deleted ${ pathType } at ${ path } `
117
+ ) ,
118
+ ] ,
119
+ } ,
91
120
} ,
92
121
} ,
93
122
} ,
@@ -96,16 +125,10 @@ const createFSMachine = (
96
125
} ,
97
126
{
98
127
actions : {
99
- createAndProcessNode ( _ , { pathType, path } , { state } ) {
100
- if ( state . matches ( `BOOTSTRAP.BOOTSTRAPPED` ) ) {
101
- reporter . info ( `added ${ pathType } at ${ path } ` )
102
- }
128
+ createAndProcessNode ( _ , { pathType, path } ) {
103
129
createAndProcessNode ( path ) . catch ( err => reporter . error ( err ) )
104
130
} ,
105
131
deletePathNode ( _ , { pathType, path } , { state } ) {
106
- if ( state . matches ( `BOOTSTRAP.BOOTSTRAPPED` ) ) {
107
- reporter . info ( `${ pathType } deleted at ${ path } ` )
108
- }
109
132
deletePathNode ( path )
110
133
} ,
111
134
flushPathQueue ( _ , { resolve, reject } ) {
@@ -128,11 +151,8 @@ exports.sourceNodes = (api, pluginOptions) => {
128
151
if ( ! fs . existsSync ( pluginOptions . path ) ) {
129
152
api . reporter . panic ( `
130
153
The path passed to gatsby-source-filesystem does not exist on your file system:
131
-
132
154
${ pluginOptions . path }
133
-
134
155
Please pick a path to an existing directory.
135
-
136
156
See docs here - https://www.gatsbyjs.org/packages/gatsby-source-filesystem/
137
157
` )
138
158
}
0 commit comments