@@ -6,6 +6,15 @@ interface NetlifyUtils {
6
6
restore : ( path : string , options ?: Partial < { cwd : string } > ) => Promise < boolean > ;
7
7
save : ( path : string , options ?: Partial < { digests : string [ ] ; cwd : string ; ttl : number } > ) => Promise < boolean > ;
8
8
} ;
9
+ build : {
10
+ failBuild : ( message : string ) => unknown ;
11
+ failPlugin : ( message : string ) => unknown ;
12
+ cancelBuild : ( message : string ) => unknown ;
13
+ } ;
14
+ status : {
15
+ /** @see https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#logging */
16
+ show : ( status : { title ?: string ; summary : string ; text ?: string } ) => unknown ;
17
+ } ;
9
18
}
10
19
11
20
interface NetlifyInputs {
@@ -64,9 +73,12 @@ module.exports = {
64
73
console . log ( `${ paths . absolute . buildDir } ${ existsSync ( paths . absolute . buildDir ) ? 'exists' : 'does not exist' } on disk` ) ;
65
74
66
75
if ( success ) {
67
- console . log ( `Restored the cached ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
76
+ const message = `Restored the cached ${ paths . buildDirName } folder at the location ${ paths . absolute . buildDir } ` ;
77
+
78
+ console . log ( message ) ;
79
+ utils . status . show ( { summary : `Restored the ${ paths . buildDirName } folder` , text : message } ) ;
68
80
} else {
69
- console . log ( `Couldn't restore the cache for the ${ paths . buildDirName } folder at the location \` ${ paths . absolute . buildDir } \` ` ) ;
81
+ utils . build . failPlugin ( `Couldn't restore the cache for the ${ paths . buildDirName } folder at the location ${ paths . absolute . buildDir } ` ) ;
70
82
}
71
83
} ,
72
84
// Cache file/directory for future builds.
@@ -85,9 +97,12 @@ module.exports = {
85
97
} ) ;
86
98
87
99
if ( success ) {
88
- console . log ( `Cached the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
100
+ const message = `Cached the ${ paths . buildDirName } folder at the location ${ paths . absolute . buildDir } ` ;
101
+
102
+ console . log ( message ) ;
103
+ utils . status . show ( { summary : `Saved the ${ paths . buildDirName } folder` , text : message } ) ;
89
104
} else {
90
- console . log ( `Couldn't cache the ${ paths . buildDirName } folder at the location \` ${ paths . absolute . buildDir } \` ` ) ;
105
+ utils . build . failPlugin ( `Couldn't cache the ${ paths . buildDirName } folder at the location ${ paths . absolute . buildDir } ` ) ;
91
106
}
92
107
}
93
108
} ;
0 commit comments