Skip to content
This repository was archived by the owner on Jan 2, 2022. It is now read-only.

Commit 87bcef5

Browse files
committed
feat: improve logging output for debugging
1 parent 5b214a9 commit 87bcef5

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
import {existsSync} from 'fs';
12
import {join as joinPaths} from 'path';
23
import {ReadonlyDeep} from 'type-fest';
34

45
interface NetlifyUtils {
56
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>;
89
};
910
}
1011

1112
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
1314
custom_build_dir_name: string;
1415
build_dir_path: string;
1516
}
@@ -61,10 +62,12 @@ module.exports = {
6162
const paths = generateAbsolutePaths({inputs});
6263
const success = await utils.cache.restore(paths.absolute.buildDir);
6364

65+
console.log(`${paths.absolute.buildDir} ${existsSync(paths.absolute.buildDir) ? 'exists' : 'does not exist'} on disk`);
66+
6467
if (success) {
6568
console.log(`Restored the cached ${paths.buildDirName} folder at the location \`${paths.absolute.buildDir}\``);
6669
} 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}\``);
6871
}
6972
},
7073
// Cache file/directory for future builds.
@@ -76,14 +79,16 @@ module.exports = {
7679
async onPostBuild({utils, inputs}: ReadonlyDeep<NetlifyOpts>) {
7780
const paths = generateAbsolutePaths({inputs});
7881

82+
console.log(`${paths.absolute.buildDir} ${existsSync(paths.absolute.buildDir) ? 'exists' : 'does not exist'} on disk`);
83+
7984
const success = await utils.cache.save(paths.absolute.buildDir, {
8085
digests: [paths.absolute.manifest]
8186
});
8287

8388
if (success) {
8489
console.log(`Cached the ${paths.buildDirName} folder at the location \`${paths.absolute.buildDir}\``);
8590
} 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}\``);
8792
}
8893
}
8994
};

0 commit comments

Comments
 (0)