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

@easy-breezy/core

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@easy-breezy/core - npm Package Compare versions

Comparing version 2.0.16 to 2.0.17

41

dist/modules/fs/index.js
import { dirname } from 'path';
import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'fs';
import { createHash } from 'crypto';
import output from './../output/index.js';

@@ -13,2 +14,12 @@ import i18n from './../i18n/index.js';

};
createSignature = (data) => {
if (data) {
const hash = createHash('sha256').update(data, 'utf8');
return hash.digest('hex');
}
};
getSignature = (data) => {
const result = /\/\/ Signature: ([a-z\d]+)$/gm.exec(data);
return result?.[1];
};
getOperations = () => {

@@ -27,9 +38,17 @@ return this.operations;

};
createFile = (path, data) => {
write = (path, data, sign = false) => {
let payload = data;
if (sign && !path.endsWith('.json')) {
const signature = this.createSignature(data);
payload = `// Signature: ${signature}\n${payload}`;
}
writeFileSync(path, payload, {
encoding: 'utf8'
});
};
createFile = (path, data, sign) => {
const existsFile = this.exists(path);
if (!existsFile) {
this.createDir(path);
writeFileSync(path, data, {
encoding: 'utf8'
});
this.write(path, data, sign);
this.operations.created.push(path);

@@ -40,9 +59,13 @@ output.info(i18n.t('core.fs.create.file', { path }));

};
updateFile = (path, data) => {
if (this.createFile(path, data)) {
updateFile = (path, data, sign) => {
if (this.createFile(path, data, sign)) {
const file = this.readFile(path);
if (file !== data) {
writeFileSync(path, data, {
encoding: 'utf8'
});
if (sign) {
const signature = this.createSignature(data);
if (this.getSignature(file) === signature) {
return;
}
}
this.write(path, data, sign);
this.operations.changed.push(path);

@@ -49,0 +72,0 @@ output.info(i18n.t('core.fs.create.update', { path }));

export declare class FS {
private operations;
private createSignature;
private getSignature;
getOperations: () => Record<"created" | "changed" | "removed" | "read" | "exists", string[]>;
createDir: (path: string) => void;
createFile: (path: string, data: string) => boolean;
updateFile: (path: string, data: string) => void;
private write;
createFile: (path: string, data: string, sign?: boolean) => boolean;
updateFile: (path: string, data: string, sign?: boolean) => void;
readFile: (path: string) => string;

@@ -8,0 +11,0 @@ exists: (path: string) => boolean;

{
"name": "@easy-breezy/core",
"version": "2.0.16",
"version": "2.0.17",
"main": "dist/index.js",

@@ -49,3 +49,3 @@ "type": "module",

"enquirer": "2.3.6",
"i18next": "22.4.12",
"i18next": "22.4.13",
"lodash.get": "4.4.2",

@@ -52,0 +52,0 @@ "lodash.setwith": "4.3.2"

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