1
+ import { existsSync } from 'fs' ;
1
2
import { join as joinPaths } from 'path' ;
2
3
import { ReadonlyDeep } from 'type-fest' ;
3
4
4
5
interface NetlifyUtils {
5
6
cache : {
6
- restore : ( path : string , options ?: Partial < { move : boolean } > ) => Promise < any > ;
7
- save : ( path : string , options ?: Partial < { digests : string [ ] ; move : boolean ; ttl : number } > ) => Promise < any > ;
7
+ restore : ( path : string , options ?: Partial < { cwd : string } > ) => Promise < boolean > ;
8
+ save : ( path : string , options ?: Partial < { digests : string [ ] ; cwd : string ; ttl : number } > ) => Promise < boolean > ;
8
9
} ;
9
10
}
10
11
11
12
interface NetlifyInputs {
12
- // The TOML config uses camelcase for readability and because it's convention
13
+ // The TOML config uses snakecase for readability and because it's convention
13
14
custom_build_dir_name : string ;
14
15
build_dir_path : string ;
15
16
}
@@ -61,10 +62,12 @@ module.exports = {
61
62
const paths = generateAbsolutePaths ( { inputs} ) ;
62
63
const success = await utils . cache . restore ( paths . absolute . buildDir ) ;
63
64
65
+ console . log ( `${ paths . absolute . buildDir } ${ existsSync ( paths . absolute . buildDir ) ? 'exists' : 'does not exist' } on disk` ) ;
66
+
64
67
if ( success ) {
65
68
console . log ( `Restored the cached ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
66
69
} else {
67
- console . log ( `No cache found for the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
70
+ console . log ( `Couldn't restore the cache for the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
68
71
}
69
72
} ,
70
73
// Cache file/directory for future builds.
@@ -76,14 +79,16 @@ module.exports = {
76
79
async onPostBuild ( { utils, inputs} : ReadonlyDeep < NetlifyOpts > ) {
77
80
const paths = generateAbsolutePaths ( { inputs} ) ;
78
81
82
+ console . log ( `${ paths . absolute . buildDir } ${ existsSync ( paths . absolute . buildDir ) ? 'exists' : 'does not exist' } on disk` ) ;
83
+
79
84
const success = await utils . cache . save ( paths . absolute . buildDir , {
80
85
digests : [ paths . absolute . manifest ]
81
86
} ) ;
82
87
83
88
if ( success ) {
84
89
console . log ( `Cached the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
85
90
} else {
86
- console . log ( `No ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
91
+ console . log ( `Couldn't cache the ${ paths . buildDirName } folder at the location \`${ paths . absolute . buildDir } \`` ) ;
87
92
}
88
93
}
89
94
} ;
0 commit comments