Socket
Socket
Sign inDemoInstall

@ui5/fs

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ui5/fs - npm Package Compare versions

Comparing version 3.0.0-alpha.2 to 3.0.0-alpha.3

CHANGELOG.md

2

lib/AbstractReader.js

@@ -91,3 +91,3 @@ const randomInt = require("random-int");

/**
* Create a [Transform-Reader]{@link module:@ui5/fs.readers.Transform} from the current reader
* Create a [Transformer-Reader]{@link module:@ui5/fs.readers.Transformer} from the current reader
*

@@ -94,0 +94,0 @@ * @public

const log = require("@ui5/logger").getLogger("resources:adapters:FileSystem");
const path = require("path");
const {promisify} = require("util");
const fs = require("graceful-fs");
const copyFile = promisify(fs.copyFile);
const chmod = promisify(fs.chmod);
const globby = require("globby");

@@ -10,2 +13,4 @@ const makeDir = require("make-dir");

const READ_ONLY_MODE = 0o444;
/**

@@ -30,3 +35,3 @@ * File system resource adapter

super({virBasePath, project, excludes});
this._fsBasePath = fsBasePath;
this._fsBasePath = path.resolve(fsBasePath);
}

@@ -64,2 +69,6 @@

path: this._virBaseDir,
source: {
adapter: "FileSystem",
fsPath: this._fsBasePath
},
createStream: () => {

@@ -97,2 +106,6 @@ return fs.createReadStream(this._fsBasePath);

path: virPath,
source: {
adapter: "FileSystem",
fsPath: fsPath
},
createStream: () => {

@@ -164,3 +177,6 @@ return fs.createReadStream(fsPath);

path: virPath,
fsPath
source: {
adapter: "FileSystem",
fsPath
}
};

@@ -209,9 +225,26 @@

await makeDir(dirPath, {fs});
const resourceSource = resource.getSource();
if (!resourceSource.modified && resourceSource.adapter === "FileSystem" && resourceSource.fsPath) {
// fs.copyFile can be used when the resource is from FS and hasn't been modified
// In addition, nothing needs to be done when src === dest
if (resourceSource.fsPath === fsPath) {
log.verbose("Skip writing to %s (Resource hasn't been modified)", fsPath);
} else {
log.verbose("Copying resource from %s to %s", resourceSource.fsPath, fsPath);
await copyFile(resourceSource.fsPath, fsPath);
if (readOnly) {
await chmod(fsPath, READ_ONLY_MODE);
}
}
return;
}
log.verbose("Writing to %s", fsPath);
await makeDir(dirPath, {fs});
return new Promise((resolve, reject) => {
let contentStream;
if (drain || readOnly) {
if ((drain || readOnly) && resourceSource.fsPath !== fsPath) {
// Stream will be drained

@@ -242,3 +275,3 @@ contentStream = resource.getStream();

if (readOnly) {
writeOptions.mode = 0o444; // read only
writeOptions.mode = READ_ONLY_MODE;
}

@@ -245,0 +278,0 @@

@@ -41,5 +41,6 @@ const stream = require("stream");

* In some cases this is the most memory-efficient way to supply resource content
* @param {object} [parameters.source] Experimental, internal parameter. Do not use
* @param {object} [parameters.project] Experimental, internal parameter. Do not use
*/
constructor({path, statInfo, buffer, string, createStream, stream, project}) {
constructor({path, statInfo, buffer, string, createStream, stream, source, project}) {
if (!path) {

@@ -57,2 +58,7 @@ throw new Error("Cannot create Resource: path parameter missing");

this._project = project; // Experimental, internal parameter
this._source = source; // Experimental, internal parameter
if (this._source) {
// Indicator for adapters like FileSystem to detect whether a resource has been changed
this._source.modified = false;
}
this._statInfo = statInfo || { // TODO

@@ -118,2 +124,5 @@ isFile: fnTrue,

setBuffer(buffer) {
if (this._source && !this._source.modified) {
this._source.modified = true;
}
this._createStream = null;

@@ -202,2 +211,5 @@ // if (this._stream) { // TODO this may cause strange issues

setStream(stream) {
if (this._source && !this._source.modified) {
this._source.modified = true;
}
this._buffer = null;

@@ -330,2 +342,6 @@ // if (this._stream) { // TODO this may cause strange issues

getSource() {
return this._source || {};
}
/**

@@ -369,3 +385,11 @@ * Returns the content as stream.

const buffer = Buffer.concat(buffers);
let modified;
if (this._source) {
modified = this._source.modified;
}
this.setBuffer(buffer);
// Modified flag should be reset as the resource hasn't been modified from the outside
if (this._source) {
this._source.modified = modified;
}
this._buffering = null;

@@ -372,0 +396,0 @@ resolve(buffer);

{
"name": "@ui5/fs",
"version": "3.0.0-alpha.2",
"version": "3.0.0-alpha.3",
"description": "UI5 Tooling - File System Abstraction",

@@ -40,5 +40,5 @@ "author": {

"preversion": "npm test",
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
"version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
"postversion": "git push --follow-tags",
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
"release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version",
"depcheck": "depcheck --ignores docdash"

@@ -48,2 +48,3 @@ },

"index.js",
"CHANGELOG.md",
"CONTRIBUTING.md",

@@ -50,0 +51,0 @@ "jsdoc.json",

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