fix(core): update

This commit is contained in:
2023-11-25 18:11:31 +01:00
parent a2dd2ab6f0
commit e00eaca362
10 changed files with 2573 additions and 12729 deletions

View File

@ -2,7 +2,7 @@
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartgulp',
version: '3.0.0',
name: '@push.rocks/smartgulp',
version: '3.0.1',
description: 'lightweight gulp replacement'
}

View File

@ -1,7 +1,7 @@
// this file contains the code to generate and handle the stream
import * as plugins from './smartgulp.plugins.js';
import { Smartfile } from '@pushrocks/smartfile';
import { SmartFile } from '@push.rocks/smartfile';
import { Transform } from 'stream';
@ -11,7 +11,7 @@ export class GulpStream {
/**
* allows you to pipe a SmartfileArray into the stream
*/
async pipeSmartfileArray(smartfileArray: Smartfile[]) {
async pipeSmartfileArray(smartfileArray: SmartFile[]) {
// ensure what we get is an array
if (!Array.isArray(smartfileArray)) {
throw new Error('fileArg has unknown format');
@ -20,8 +20,6 @@ export class GulpStream {
let hasWritten = this.stream.push(smartfile);
if (!hasWritten) {
await plugins.smartevent.once(this.stream, 'drain');
} else {
// iterate
}
}
// signal end of stream;

View File

@ -3,12 +3,12 @@ import * as plugins from './smartgulp.plugins.js';
import { GulpStream } from './smartgulp.classes.gulpstream.js';
import { Transform } from 'stream';
import { Smartfile } from '@pushrocks/smartfile';
import { SmartFile } from '@push.rocks/smartfile';
export let src = (minimatchPathArrayArg: string[]): Transform => {
let gulpStream = new GulpStream();
let handleFiles = async () => {
let smartfileArray: Smartfile[] = [];
let smartfileArray: SmartFile[] = [];
for (let minimatchPath of minimatchPathArrayArg) {
let localSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
process.cwd(),
@ -24,16 +24,25 @@ export let src = (minimatchPathArrayArg: string[]): Transform => {
return gulpStream.stream;
};
export let dest = (dirArg: string) => {};
export let dest = (dirArg: string) => {
const stream = new plugins.smartstream.SmartDuplex({
objectMode: true,
writeFunction: async (fileArg: SmartFile) => {
const filePath = plugins.path.join(dirArg, fileArg.relative);
const dirPath = plugins.path.dirname(filePath);
await plugins.smartfile.fs.ensureDir(dirPath);
await plugins.smartfile.memory.toFs(fileArg.contentBuffer, filePath);
}
});
return stream;
};
export let replace = () => {
return plugins.through2.obj(
async (file: Smartfile, enc, cb) => {
await file.write();
cb(null, file);
},
(cb) => {
cb();
const stream = new plugins.smartstream.SmartDuplex({
objectMode: true,
writeFunction: async (fileArg: SmartFile) => {
await fileArg.write();
}
);
});
return stream;
};

View File

@ -1,6 +1,14 @@
import * as smartevent from '@pushrocks/smartevent';
import * as smartfile from '@pushrocks/smartfile';
import * as smartstream from '@pushrocks/smartstream';
// node native scope
import * as path from 'path';
export {
path
};
// @push.rocks scope
import * as smartevent from '@push.rocks/smartevent';
import * as smartfile from '@push.rocks/smartfile';
import * as smartstream from '@push.rocks/smartstream';
import * as through2 from 'through2';
export { smartevent, smartfile, smartstream, through2 };