Skip to content

Commit

Permalink
refactor: Adapt shared to modern logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Nov 25, 2021
1 parent 1c8f911 commit 8ff97e6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const sha256File = require('sha256-file');
* @param {Object} serverless
* @return {undefined}
*/
function checkForAndDeleteMaxCacheVersions(options, serverless) {
function checkForAndDeleteMaxCacheVersions({ serverless, options, log }) {
// If we're using the static cache, and we have static cache max versions enabled
if (
options.useStaticCache &&
Expand Down Expand Up @@ -42,10 +42,17 @@ function checkForAndDeleteMaxCacheVersions(options, serverless) {
rimraf.sync(files[i]);
items++;
}

// Log the number of cache files flushed
serverless.cli.log(
`Removed ${items} items from cache because of staticCacheMaxVersions`
);
if (log) {
log.info(
`Removed ${items} items from cache because of staticCacheMaxVersions`
);
} else {
serverless.cli.log(
`Removed ${items} items from cache because of staticCacheMaxVersions`
);
}
}
}
}
Expand Down

0 comments on commit 8ff97e6

Please sign in to comment.