Skip to content

Commit

Permalink
perf: avoid extra call stat for file (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Mar 22, 2019
1 parent 94086af commit ae2258f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/postProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export default function postProcessPattern(globalRef, pattern, file) {

logger.debug(`getting stats for '${file.absoluteFrom}' to write to assets`);

return stat(inputFileSystem, file.absoluteFrom).then((stats) => {
const getStats = pattern.stats
? Promise.resolve().then(() => pattern.stats)
: stat(inputFileSystem, file.absoluteFrom);

return getStats.then((stats) => {
// We don't write empty directories
if (stats.isDirectory()) {
logger.debug(
Expand Down
1 change: 1 addition & 0 deletions src/preProcessPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export default function preProcessPattern(globalRef, pattern) {

fileDependencies.add(pattern.absoluteFrom);

pattern.stats = stats;
pattern.fromType = 'file';
pattern.context = path.dirname(pattern.absoluteFrom);
pattern.glob = normalize(pattern.absoluteFrom);
Expand Down

0 comments on commit ae2258f

Please sign in to comment.