Skip to content

Commit

Permalink
Fix no-prototype-builtins error
Browse files Browse the repository at this point in the history
This fix doesn't seem to break anything, though I'll admit it's straight off stackoverflow.
  • Loading branch information
domoscargin committed Dec 5, 2022
1 parent cb0f281 commit 6079eb8
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions lib/file-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,22 @@ exports.getFingerprint = function (file) {
// We only know the path of the current file when we're compiling the layout –
// calls to this function with a relative path will fail if made from the
// source files themselves.
if (filePath) {
// Use path.join to correctly join, but metalsmith-fingerprint-ignore
// always expects forward slashes, so replace any backslashes (Windows)
// with a forward slashes.
const relativeFile = path.join(filePath, file).replace(/\\/g, '/')

if (fingerprints.hasOwnProperty(relativeFile)) {
return '/' + fingerprints[relativeFile]
}
}

// Look for a fingerprinted asset at this path relative to the site root
if (fingerprints.hasOwnProperty(file)) {
return '/' + fingerprints[file]
if (!fingerprints[file] && filePath) {
// Use path.join to correctly join, but metalsmith-fingerprint-ignore
// always expects forward slashes, so replace any backslashes (Windows)
// with a forward slashes.
file = path.join(filePath, file).replace(/\\/g, '/')
}

// The thrown error will stop the build, but not provide any useful output,
// so we have to console.log as well.
console.log(`Could not find fingerprint for file ${file}`)
throw new Error(`Could not find fingerprint for file ${file}`)
if (!fingerprints[file]) {
console.log(`Could not find fingerprint for file ${file}`)
throw new Error(`Could not find fingerprint for file ${file}`)
}

// Look for a fingerprinted asset at this path relative to the site root
return '/' + fingerprints[file]
}

// This helper function takes a path of a *.md.njk file and
Expand Down

0 comments on commit 6079eb8

Please sign in to comment.