Compare commits

...

11 Commits

Author SHA1 Message Date
219e070ba2 10.0.31 2023-08-31 18:45:24 +02:00
ee97e1d88b fix(core): update 2023-08-31 18:45:23 +02:00
279db74568 10.0.30 2023-08-23 10:58:38 +02:00
b84c504f11 fix(core): update 2023-08-23 10:58:38 +02:00
7b3194cc13 10.0.29 2023-08-23 09:38:49 +02:00
e1e821efec fix(core): update 2023-08-23 09:38:49 +02:00
6b613d1b8a 10.0.28 2023-07-12 10:00:40 +02:00
70f1c58a82 fix(core): update 2023-07-12 10:00:40 +02:00
5df76ca94b 10.0.27 2023-07-10 23:07:51 +02:00
32cfda3c90 fix(core): update 2023-07-10 23:07:50 +02:00
dd521398ea switch to new org scheme 2023-07-10 02:55:52 +02:00
9 changed files with 1764 additions and 552 deletions

View File

@ -8,10 +8,10 @@
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "push.rocks",
"gitrepo": "smartfile", "gitrepo": "smartfile",
"description": "smart ways to work with files in nodejs", "description": "smart ways to work with files in nodejs",
"npmPackagename": "@pushrocks/smartfile", "npmPackagename": "@push.rocks/smartfile",
"license": "MIT" "license": "MIT"
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "@pushrocks/smartfile", "name": "@push.rocks/smartfile",
"private": false, "private": false,
"version": "10.0.26", "version": "10.0.31",
"description": "offers smart ways to work with files in nodejs", "description": "offers smart ways to work with files in nodejs",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
@ -26,30 +26,29 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartfile", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^6.0.2", "@push.rocks/lik": "^6.0.5",
"@pushrocks/smartdelay": "^3.0.1", "@push.rocks/smartdelay": "^3.0.5",
"@pushrocks/smartfile-interfaces": "^1.0.7", "@push.rocks/smartfile-interfaces": "^1.0.7",
"@pushrocks/smarthash": "^3.0.2", "@push.rocks/smarthash": "^3.0.2",
"@pushrocks/smartjson": "^5.0.6", "@push.rocks/smartjson": "^5.0.10",
"@pushrocks/smartmime": "^1.0.5", "@push.rocks/smartmime": "^1.0.5",
"@pushrocks/smartpath": "^5.0.5", "@push.rocks/smartpath": "^5.0.11",
"@pushrocks/smartpromise": "^4.0.2", "@push.rocks/smartpromise": "^4.0.2",
"@pushrocks/smartrequest": "^2.0.15", "@push.rocks/smartrequest": "^2.0.18",
"@pushrocks/smartstream": "^2.0.3", "@push.rocks/smartstream": "^2.0.4",
"@pushrocks/streamfunction": "^4.0.4",
"@types/fs-extra": "^11.0.1", "@types/fs-extra": "^11.0.1",
"@types/glob": "^8.1.0", "@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.5", "@types/js-yaml": "^4.0.5",
"fs-extra": "^11.1.1", "fs-extra": "^11.1.1",
"glob": "^10.3.2", "glob": "^10.3.4",
"js-yaml": "^4.1.0" "js-yaml": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.66", "@git.zone/tsbuild": "^2.1.70",
"@gitzone/tsrun": "^1.2.42", "@git.zone/tsrun": "^1.2.46",
"@gitzone/tstest": "^1.0.74", "@git.zone/tstest": "^1.0.80",
"@pushrocks/tapbundle": "^5.0.8", "@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.4.1" "@types/node": "^20.5.7"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

2200
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
import * as smartfile from '../ts/index.js'; import * as smartfile from '../ts/index.js';
import * as path from 'path'; import * as path from 'path';
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@push.rocks/tapbundle';
// --------------------------- // ---------------------------
// smartfile.fs // smartfile.fs

View File

@ -1,4 +1,4 @@
import { tap, expect } from '@pushrocks/tapbundle'; import { tap, expect } from '@push.rocks/tapbundle';
import * as smartfile from '../ts/index.js'; import * as smartfile from '../ts/index.js';

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @pushrocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@pushrocks/smartfile', name: '@push.rocks/smartfile',
version: '10.0.26', version: '10.0.31',
description: 'offers smart ways to work with files in nodejs' description: 'offers smart ways to work with files in nodejs'
} }

View File

@ -40,7 +40,18 @@ export const fileExists = async (filePath): Promise<boolean> => {
/** /**
* Checks if given path points to an existing directory * Checks if given path points to an existing directory
*/ */
export const isDirectory = (pathArg): boolean => { export const isDirectory = (pathArg: string): boolean => {
try {
return plugins.fsExtra.statSync(pathArg).isDirectory();
} catch (err) {
return false;
}
};
/**
* Checks if given path points to an existing directory
*/
export const isDirectorySync = (pathArg: string): boolean => {
try { try {
return plugins.fsExtra.statSync(pathArg).isDirectory(); return plugins.fsExtra.statSync(pathArg).isDirectory();
} catch (err) { } catch (err) {
@ -244,12 +255,12 @@ export const fileTreeToObject = async (dirPathArg: string, miniMatchFilter: stri
return filePath; return filePath;
} }
})(); })();
const fileContentString = toStringSync(readPath); const fileBuffer = plugins.fs.readFileSync(readPath);
// push a read file as Smartfile // push a read file as Smartfile
smartfileArray.push( smartfileArray.push(
new Smartfile({ new Smartfile({
contentBuffer: Buffer.from(fileContentString), contentBuffer: fileBuffer,
base: dirPath, base: dirPath,
path: filePath, path: filePath,
}) })

View File

@ -11,4 +11,29 @@ export const createWriteStream = (pathArg: string) => {
return plugins.fs.createWriteStream(pathArg); return plugins.fs.createWriteStream(pathArg);
}; };
export const streamDirectory = async (dirPathArg: string) => {}; export const processFile = async (
filePath: string,
asyncFunc: (fileStream: plugins.stream.Readable) => Promise<void>
): Promise<void> => {
return new Promise((resolve, reject) => {
const fileStream = createReadStream(filePath);
asyncFunc(fileStream).then(resolve).catch(reject);
});
}
export const processDirectory = async (
directoryPath: string,
asyncFunc: (fileStream: plugins.stream.Readable) => Promise<void>
): Promise<void> => {
const files = plugins.fs.readdirSync(directoryPath, { withFileTypes: true });
for (const file of files) {
const fullPath = plugins.path.join(directoryPath, file.name);
if (file.isDirectory()) {
await processDirectory(fullPath, asyncFunc); // Recursively call processDirectory for directories
} else if (file.isFile()) {
await processFile(fullPath, asyncFunc); // Call async function with the file stream and wait for it
}
}
};

View File

@ -1,20 +1,21 @@
// node native scope // node native scope
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as stream from 'stream';
export { fs, path }; export { fs, path, stream };
// @pushrocks scope // @pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@push.rocks/lik';
import * as smartfileInterfaces from '@pushrocks/smartfile-interfaces'; import * as smartfileInterfaces from '@push.rocks/smartfile-interfaces';
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@push.rocks/smartdelay';
import * as smarthash from '@pushrocks/smarthash'; import * as smarthash from '@push.rocks/smarthash';
import * as smartjson from '@pushrocks/smartjson'; import * as smartjson from '@push.rocks/smartjson';
import * as smartmime from '@pushrocks/smartmime'; import * as smartmime from '@push.rocks/smartmime';
import * as smartpath from '@pushrocks/smartpath'; import * as smartpath from '@push.rocks/smartpath';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@push.rocks/smartrequest';
import * as smartstream from '@pushrocks/smartstream'; import * as smartstream from '@push.rocks/smartstream';
export { export {
lik, lik,