FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Read file before creating directory by timneutkens · Pull Request #644 · babel/babel-loader · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 8 additions & 8 deletions src/cache.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ const filename = function(source, identifier, options) {
const handleCache = async function(directory, params) {
const { source, options = {}, cacheIdentifier, cacheDirectory } = params;

const file = path.join(directory, filename(source, cacheIdentifier, options));

try {
// No errors mean that the file was previously cached
// we just need to return it
return await read(file);
} catch (err) {}

const fallback =
typeof cacheDirectory !== "string" && directory !== os.tmpdir();

Expand All @@ -94,14 +102,6 @@ const handleCache = async function(directory, params) {
throw err;
}

const file = path.join(directory, filename(source, cacheIdentifier, options));

try {
// No errors mean that the file was previously cached
// we just need to return it
return await read(file);
} catch (err) {}

// Otherwise just transform the file
// return it to the user asap and write it in cache
const result = await transform(source, options);
Expand Down

Back | FazBrowse Home | New Git URL