Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@docusaurus/utils

Package Overview
Dependencies
Maintainers
3
Versions
1839
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/utils - npm Package Compare versions

Comparing version 2.0.0-alpha.36 to 2.0.0-alpha.37

43

lib/index.js

@@ -8,11 +8,2 @@ "use strict";

*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -29,20 +20,18 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

const fileHash = new Map();
function generate(generatedFilesDir, file, content, skipCache = process.env.NODE_ENV === 'production') {
return __awaiter(this, void 0, void 0, function* () {
const filepath = path_1.default.join(generatedFilesDir, file);
if (skipCache) {
yield fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
yield fs_extra_1.default.writeFile(filepath, content);
return;
}
const lastHash = fileHash.get(filepath);
const currentHash = crypto_1.createHash('md5')
.update(content)
.digest('hex');
if (lastHash !== currentHash) {
yield fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
yield fs_extra_1.default.writeFile(filepath, content);
fileHash.set(filepath, currentHash);
}
});
async function generate(generatedFilesDir, file, content, skipCache = process.env.NODE_ENV === 'production') {
const filepath = path_1.default.join(generatedFilesDir, file);
if (skipCache) {
await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
await fs_extra_1.default.writeFile(filepath, content);
return;
}
const lastHash = fileHash.get(filepath);
const currentHash = crypto_1.createHash('md5')
.update(content)
.digest('hex');
if (lastHash !== currentHash) {
await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
await fs_extra_1.default.writeFile(filepath, content);
fileHash.set(filepath, currentHash);
}
}

@@ -49,0 +38,0 @@ exports.generate = generate;

{
"name": "@docusaurus/utils",
"version": "2.0.0-alpha.36",
"version": "2.0.0-alpha.37",
"description": "Node utility functions for Docusaurus packages",

@@ -20,3 +20,6 @@ "main": "./lib/index.js",

},
"gitHead": "c413cff212196c440420ef7f3cac9856b766c5a3"
"engines": {
"node": ">= 8.10.0"
},
"gitHead": "464d8e529a8a49be02f59ecc600cd5de3d1ef40f"
}

@@ -260,2 +260,6 @@ /**

},
{
input: ['http://foobar.com', '', 'test', '/'],
output: 'http://foobar.com/test/',
},
];

@@ -265,3 +269,9 @@ asserts.forEach(testCase => {

});
expect(() =>
normalizeUrl(['http:example.com', undefined]),
).toThrowErrorMatchingInlineSnapshot(
`"Url must be a string. Received undefined"`,
);
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc