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

file-stat

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-stat - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

43

index.js

@@ -31,3 +31,7 @@ 'use strict';

if (err) {
cb(err);
if (err.code === 'ENOENT') {
cb(null, file);
} else {
cb(err);
}
return;

@@ -60,3 +64,7 @@ }

if (err) {
cb(err);
if (err.code === 'ENOENT') {
cb(null, file);
} else {
cb(err);
}
return;

@@ -88,3 +96,5 @@ }

function statSync(file) {
utils.fileExists(file);
var stat;
Object.defineProperty(file, 'stat', {

@@ -96,3 +106,10 @@ configurable: true,

get: function() {
return stat || (stat = utils.fs.statSync(this.path));
if (stat) {
return stat;
}
if (this.exists) {
stat = utils.fs.statSync(this.path);
return stat;
}
return null;
}

@@ -120,3 +137,5 @@ });

function lstatSync(file) {
utils.fileExists(file);
var lstat;
Object.defineProperty(file, 'lstat', {

@@ -128,3 +147,10 @@ configurable: true,

get: function() {
return lstat || (lstat = utils.fs.lstatSync(this.path));
if (lstat) {
return lstat;
}
if (this.exists) {
lstat = utils.fs.lstatSync(this.path);
return lstat;
}
return null;
}

@@ -139,3 +165,10 @@ });

get: function() {
return lstat || (lstat = utils.fs.lstatSync(this.path));
if (lstat) {
return lstat;
}
if (this.exists) {
lstat = utils.fs.lstatSync(this.path);
return lstat;
}
return null;
}

@@ -142,0 +175,0 @@ });

3

package.json
{
"name": "file-stat",
"description": "Set the `stat` property on a file object. Abstraction from vinyl-fs to support stream or non-stream usage.",
"version": "0.2.2",
"version": "0.2.3",
"homepage": "https://github.com/jonschlinkert/file-stat",

@@ -24,2 +24,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"dependencies": {
"fs-exists-sync": "^0.1.0",
"graceful-fs": "^4.1.4",

@@ -26,0 +27,0 @@ "lazy-cache": "^2.0.1",

@@ -13,8 +13,23 @@ 'use strict';

require('through2', 'through');
require('fs-exists-sync', 'exists');
require = fn;
/**
* Reset require
*/
utils.fileExists = function(file) {
if ('exists' in file) return;
var exists;
require = fn;
Object.defineProperty(file, 'exists', {
configurable: true,
set: function(val) {
exists = val;
},
get: function fn() {
if (typeof exists === 'boolean') {
return exists;
}
exists = utils.exists(this.path);
return exists;
}
});
};

@@ -21,0 +36,0 @@ /**

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