@docusaurus/utils
Advanced tools
Comparing version 2.0.0-alpha.11 to 2.0.0-alpha.12
{ | ||
"name": "@docusaurus/utils", | ||
"version": "2.0.0-alpha.11", | ||
"version": "2.0.0-alpha.12", | ||
"description": "Node utility functions for Docusaurus packages", | ||
@@ -16,3 +16,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "7339bfea353bea6c904b7078e370a9b224c96cca" | ||
"gitHead": "86c24e9cf520535a8c94a1448b06df0e757677d4" | ||
} |
@@ -16,9 +16,14 @@ /** | ||
const genCache = new Map(); | ||
const fileHash = new Map(); | ||
async function generate(generatedFilesDir, file, content) { | ||
const cached = genCache.get(file); | ||
if (cached !== content) { | ||
await fs.ensureDir(generatedFilesDir); | ||
await fs.writeFile(path.join(generatedFilesDir, file), content); | ||
genCache.set(file, content); | ||
const filepath = path.join(generatedFilesDir, file); | ||
const lastHash = fileHash.get(filepath); | ||
const currentHash = createHash('md5') | ||
.update(content) | ||
.digest('hex'); | ||
if (lastHash !== currentHash) { | ||
await fs.ensureDir(path.dirname(filepath)); | ||
await fs.writeFile(filepath, content); | ||
fileHash.set(filepath, currentHash); | ||
} | ||
@@ -25,0 +30,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13113
388