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

syntex-filesystem

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

syntex-filesystem - npm Package Compare versions

Comparing version 1.0.3-b1 to 1.0.3-b10

0

.eslintrc.json

@@ -0,0 +0,0 @@ {

156

main.js

@@ -41,6 +41,2 @@ const fs = require('fs'), path = require('path');

}
else
{
this.logger.log('error', 'bridge', 'Bridge', '%no_base_path%!');
}
}

@@ -59,10 +55,25 @@

{
var absPath = path.join(this.basePath, directory);
this.createDirectory(directory);
}
}
}
if(!fs.existsSync(absPath))
{
fs.mkdirSync(absPath);
}
createDirectory(directoryPath)
{
if(this.isReady())
{
if(!path.isAbsolute(directoryPath))
{
directoryPath = path.join(this.basePath, directoryPath);
}
if(!fs.existsSync(directoryPath))
{
fs.mkdirSync(directoryPath);
return true;
}
}
return false;
}

@@ -76,2 +87,4 @@

{
var options = {};
if(!path.isAbsolute(filePath))

@@ -82,4 +95,9 @@ {

fs.readFile(filePath, { encoding : 'utf8' }, (error, file) => {
if(path.parse(filePath).ext == '.json' || path.parse(filePath).ext == '.txt')
{
options.encoding = 'utf8';
}
fs.readFile(filePath, options, (error, file) => {
if(file != null && error == null)

@@ -94,12 +112,5 @@ {

if(this.enableCache)
if(this.enableCache && path.parse(filePath).ext == '.json')
{
if(path.parse(filePath).ext == '.json')
{
cache[filePath] = JSON.stringify(file);
}
else
{
cache[filePath] = file;
}
cache[filePath] = JSON.stringify(file);
}

@@ -164,12 +175,5 @@

{
if(this.enableCache)
if(this.enableCache && path.parse(filePath).ext == '.json')
{
if(path.parse(filePath).ext == '.json')
{
cache[filePath] = JSON.stringify(JSON.parse(data));
}
else
{
cache[filePath] = data;
}
cache[filePath] = JSON.stringify(JSON.parse(data));
}

@@ -206,2 +210,30 @@ }

moveContent(fromPath, toPath)
{
return new Promise((resolve) => {
if(this.isReady() && fromPath != null && toPath != null)
{
if(!path.isAbsolute(fromPath))
{
fromPath = path.join(this.basePath, fromPath);
}
if(!path.isAbsolute(toPath))
{
toPath = path.join(this.basePath, toPath);
}
fs.rename(fromPath, toPath, (error) => {
resolve(error == null);
});
}
else
{
resolve(false);
}
});
}
deleteFile(filePath)

@@ -218,5 +250,5 @@ {

fs.unlink(filePath, (error) => {
fs.rm(filePath, { recursive : false }, (error) => {
resolve(error != null && error.code != 'ENOENT' ? false : true);
resolve(error == null);
});

@@ -231,31 +263,54 @@ }

readDirectory(filePath)
deleteDirectory(directoryPath)
{
return new Promise((resolve) => {
if(this.isReady() && filePath != null)
if(this.isReady() && directoryPath != null)
{
if(!path.isAbsolute(filePath))
if(!path.isAbsolute(directoryPath))
{
filePath = path.join(this.basePath, filePath);
directoryPath = path.join(this.basePath, directoryPath);
}
fs.readdir(filePath, (error, files) => {
fs.rm(directoryPath, { recursive : true }, (error) => {
resolve(error == null);
});
}
else
{
resolve(false);
}
});
}
readDirectory(directoryPath)
{
return new Promise((resolve) => {
if(this.isReady() && directoryPath != null)
{
if(!path.isAbsolute(directoryPath))
{
directoryPath = path.join(this.basePath, directoryPath);
}
fs.readdir(directoryPath, (error, files) => {
if(files && !error)
{
var fileArray = {};
var fileArray = {}, promiseArray = [];
for(const file of files)
{
if(fs.statSync(path.join(filePath, file)).isFile())
if(fs.statSync(path.join(directoryPath, file)).isFile())
{
this.readFile(path.join(filePath, file)).then((content) => {
promiseArray.push(this.readFile(path.join(directoryPath, file)).then((content) => {
fileArray[file] = content;
});
}));
}
}
resolve(fileArray);
Promise.all(promiseArray).then(() => resolve(fileArray));
}

@@ -275,13 +330,24 @@ else

fileChanged(filePath, data)
checkFile(filePath)
{
if(this.enableCache && cache[filePath] != null)
if(this.isReady() && filePath != null)
{
if((path.parse(filePath).ext == '.json' && cache[filePath] == JSON.stringify(data))
|| (path.parse(filePath).ext != '.json' && cache[filePath] == data))
if(!path.isAbsolute(filePath))
{
return false;
filePath = path.join(this.basePath, filePath);
}
return fs.existsSync(filePath);
}
return false;
}
fileChanged(filePath, data)
{
if(this.enableCache && cache[filePath] != null && cache[filePath] == JSON.stringify(data))
{
return false;
}
return true;

@@ -288,0 +354,0 @@ }

{
"name": "syntex-filesystem",
"version": "1.0.3-b1",
"version": "1.0.3-b10",
"description": "A Basic File System",

@@ -12,3 +12,3 @@ "main": "main.js",

"dependencies": {
"syntex-logger": "1.0.9-b1"
"syntex-logger": "1.0.9-b2"
},

@@ -15,0 +15,0 @@ "keywords": [

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