Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
36c456b509 | |||
16f8c25557 | |||
219e070ba2 | |||
ee97e1d88b | |||
279db74568 | |||
b84c504f11 | |||
7b3194cc13 | |||
e1e821efec | |||
6b613d1b8a | |||
70f1c58a82 | |||
5df76ca94b | |||
32cfda3c90 | |||
dd521398ea |
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
package.json
41
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartfile",
|
"name": "@push.rocks/smartfile",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "10.0.26",
|
"version": "10.0.32",
|
||||||
"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.4",
|
||||||
"@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.2",
|
||||||
"@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.6",
|
||||||
"fs-extra": "^11.1.1",
|
"fs-extra": "^11.1.1",
|
||||||
"glob": "^10.3.2",
|
"glob": "^10.3.5",
|
||||||
"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.81",
|
||||||
"@pushrocks/tapbundle": "^5.0.8",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^20.4.1"
|
"@types/node": "^20.6.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
2754
pnpm-lock.yaml
generated
2754
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -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
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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.32',
|
||||||
description: 'offers smart ways to work with files in nodejs'
|
description: 'offers smart ways to work with files in nodejs'
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
})
|
})
|
||||||
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -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,
|
||||||
|
Reference in New Issue
Block a user