@@ -17,7 +17,7 @@ function readFile(file, pluginOptions, cb) {
1717 // Stringify date objects.
1818 const newFile = JSON . parse (
1919 JSON . stringify ( {
20- id : `${ slashedFile . absolutePath } >>> ${ contentDigest } ` ,
20+ id : `${ slashedFile . absolutePath } ` ,
2121 contentDigest : contentDigest ,
2222 children : [ ] ,
2323 parent : `___SOURCE___` ,
@@ -44,7 +44,10 @@ function readFile(file, pluginOptions, cb) {
4444 } )
4545}
4646
47- exports . sourceNodes = ( { boundActionCreators, getNode } , pluginOptions ) => {
47+ exports . sourceNodes = (
48+ { boundActionCreators, getNode, hasNodeChanged } ,
49+ pluginOptions
50+ ) => {
4851 const { createNode, updateSourcePluginStatus } = boundActionCreators
4952 updateSourcePluginStatus ( {
5053 plugin : `source-filesystem --- ${ pluginOptions . name } ` ,
@@ -66,7 +69,7 @@ exports.sourceNodes = ({ boundActionCreators, getNode }, pluginOptions) => {
6669 // console.log("Added file at", path)
6770 readFile ( path , pluginOptions , ( err , file ) => {
6871 // Only create node if the content digest has changed.
69- if ( ! getNode ( file . id ) ) {
72+ if ( ! getNode ( file . id ) || hasNodeChanged ( file . id , file . contentDigest ) ) {
7073 createNode ( file )
7174 } else {
7275 // console.log("not creating node cause it already exists", file.id)
@@ -77,7 +80,7 @@ exports.sourceNodes = ({ boundActionCreators, getNode }, pluginOptions) => {
7780 console . log ( "changed file at" , path )
7881 readFile ( path , pluginOptions , ( err , file ) => {
7982 // Only create node if the content digest has changed.
80- if ( ! getNode ( file . id ) ) {
83+ if ( ! getNode ( file . id ) || hasNodeChanged ( file . id , file . contentDigest ) ) {
8184 createNode ( file )
8285 }
8386 } )
0 commit comments