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

@yarnpkg/fslib

Package Overview
Dependencies
Maintainers
5
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/fslib - npm Package Compare versions

Comparing version 2.0.0-rc.13 to 2.0.0-rc.14

49

lib/FakeFS.js

@@ -6,4 +6,7 @@ "use strict";

});
exports.normalizeLineEndings = normalizeLineEndings;
exports.BasePortableFakeFS = exports.FakeFS = void 0;
var _os = require("os");
var _copyPromise = require("./algorithms/copyPromise");

@@ -190,26 +193,30 @@

async changeFilePromise(p, content) {
async changeFilePromise(p, content, {
automaticNewlines
} = {}) {
let current = '';
try {
const current = await this.readFilePromise(p, `utf8`);
if (current === content) {
return;
}
current = await this.readFilePromise(p, `utf8`);
} catch (error) {// ignore errors, no big deal
}
await this.writeFilePromise(p, content);
const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content;
if (current === normalizedContent) return;
await this.writeFilePromise(p, normalizedContent);
}
changeFileSync(p, content) {
changeFileSync(p, content, {
automaticNewlines = false
} = {}) {
let current = '';
try {
const current = this.readFileSync(p, `utf8`);
if (current === content) {
return;
}
current = this.readFileSync(p, `utf8`);
} catch (error) {// ignore errors, no big deal
}
this.writeFileSync(p, content);
const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content;
if (current === normalizedContent) return;
this.writeFileSync(p, normalizedContent);
}

@@ -379,2 +386,14 @@

exports.BasePortableFakeFS = BasePortableFakeFS;
exports.BasePortableFakeFS = BasePortableFakeFS;
function getEndOfLine(content) {
const matches = content.match(/\r?\n/g);
if (matches === null) return _os.EOL;
const crlf = matches.filter(nl => nl === `\r\n`).length;
const lf = matches.length - crlf;
return crlf > lf ? `\r\n` : `\n`;
}
function normalizeLineEndings(originalContent, newContent) {
return newContent.replace(/\r?\n/g, getEndOfLine(originalContent));
}

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

});
Object.defineProperty(exports, "normalizeLineEndings", {
enumerable: true,
get: function () {
return _FakeFS.normalizeLineEndings;
}
});
Object.defineProperty(exports, "FakeFS", {

@@ -52,0 +58,0 @@ enumerable: true,

{
"name": "@yarnpkg/fslib",
"version": "2.0.0-rc.13",
"version": "2.0.0-rc.14",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "sideEffects": false,

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