system change
This commit is contained in:
		@@ -1 +1 @@
 | 
			
		||||
export * from './smartgulp.gulpapi'
 | 
			
		||||
export * from './smartgulp.gulpapi';
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,12 @@
 | 
			
		||||
// this file contains the code to generate and handle the stream
 | 
			
		||||
 | 
			
		||||
import * as plugins from './smartgulp.plugins'
 | 
			
		||||
import { Smartfile } from 'smartfile'
 | 
			
		||||
import * as plugins from './smartgulp.plugins';
 | 
			
		||||
import { Smartfile } from 'smartfile';
 | 
			
		||||
 | 
			
		||||
import { Transform } from 'stream'
 | 
			
		||||
import { Transform } from 'stream';
 | 
			
		||||
 | 
			
		||||
export class GulpStream {
 | 
			
		||||
  stream = new Transform({ objectMode: true })
 | 
			
		||||
  stream = new Transform({ objectMode: true });
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * allows you to pipe a SmartfileArray into the stream
 | 
			
		||||
@@ -14,17 +14,17 @@ export class GulpStream {
 | 
			
		||||
  async pipeSmartfileArray(smartfileArray: Smartfile[]) {
 | 
			
		||||
    // ensure what we get is an array
 | 
			
		||||
    if (!Array.isArray(smartfileArray)) {
 | 
			
		||||
      throw new Error('fileArg has unknown format')
 | 
			
		||||
      throw new Error('fileArg has unknown format');
 | 
			
		||||
    }
 | 
			
		||||
    for (let smartfile of smartfileArray) {
 | 
			
		||||
      let hasWritten = this.stream.push(smartfile)
 | 
			
		||||
      let hasWritten = this.stream.push(smartfile);
 | 
			
		||||
      if (!hasWritten) {
 | 
			
		||||
        await plugins.smartevent.once(this.stream, 'drain')
 | 
			
		||||
        await plugins.smartevent.once(this.stream, 'drain');
 | 
			
		||||
      } else {
 | 
			
		||||
        // iterate
 | 
			
		||||
      }
 | 
			
		||||
    };
 | 
			
		||||
    }
 | 
			
		||||
    // signal end of stream;
 | 
			
		||||
    this.stream.push(null)
 | 
			
		||||
    this.stream.push(null);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,35 +1,39 @@
 | 
			
		||||
// this file contains the implementation of the standard gulp api
 | 
			
		||||
import * as plugins from './smartgulp.plugins'
 | 
			
		||||
import { GulpStream } from './smartgulp.classes.gulpstream'
 | 
			
		||||
import { Transform } from 'stream'
 | 
			
		||||
import * as plugins from './smartgulp.plugins';
 | 
			
		||||
import { GulpStream } from './smartgulp.classes.gulpstream';
 | 
			
		||||
import { Transform } from 'stream';
 | 
			
		||||
 | 
			
		||||
import { Smartfile } from 'smartfile'
 | 
			
		||||
import { Smartfile } from 'smartfile';
 | 
			
		||||
 | 
			
		||||
export let src = (minimatchPathArrayArg: string[]): Transform => {
 | 
			
		||||
  let gulpStream = new GulpStream()
 | 
			
		||||
  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(), minimatchPath)
 | 
			
		||||
      smartfileArray = plugins.lodash.concat(smartfileArray, localSmartfileArray)
 | 
			
		||||
      let localSmartfileArray = await plugins.smartfile.fs.fileTreeToObject(
 | 
			
		||||
        process.cwd(),
 | 
			
		||||
        minimatchPath
 | 
			
		||||
      );
 | 
			
		||||
      smartfileArray = plugins.lodash.concat(smartfileArray, localSmartfileArray);
 | 
			
		||||
    }
 | 
			
		||||
    gulpStream.pipeSmartfileArray(smartfileArray)
 | 
			
		||||
  }
 | 
			
		||||
    gulpStream.pipeSmartfileArray(smartfileArray);
 | 
			
		||||
  };
 | 
			
		||||
  handleFiles().catch(err => {
 | 
			
		||||
    console.log(err)
 | 
			
		||||
  })
 | 
			
		||||
  return gulpStream.stream
 | 
			
		||||
}
 | 
			
		||||
    console.log(err);
 | 
			
		||||
  });
 | 
			
		||||
  return gulpStream.stream;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export let dest = (dirArg: string) => {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
export let dest = (dirArg: string) => {};
 | 
			
		||||
 | 
			
		||||
export let replace = () => {
 | 
			
		||||
  return plugins.through2.obj(async (file: Smartfile, enc, cb) => {
 | 
			
		||||
    await file.write()
 | 
			
		||||
    cb(null, file)
 | 
			
		||||
  }, (cb) => {
 | 
			
		||||
    cb()
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
  return plugins.through2.obj(
 | 
			
		||||
    async (file: Smartfile, enc, cb) => {
 | 
			
		||||
      await file.write();
 | 
			
		||||
      cb(null, file);
 | 
			
		||||
    },
 | 
			
		||||
    cb => {
 | 
			
		||||
      cb();
 | 
			
		||||
    }
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,7 @@
 | 
			
		||||
import * as smartevent from 'smartevent'
 | 
			
		||||
import * as smartfile from 'smartfile'
 | 
			
		||||
import * as smartstream from 'smartstream'
 | 
			
		||||
import * as lodash from 'lodash'
 | 
			
		||||
import * as through2 from 'through2'
 | 
			
		||||
import * as smartevent from 'smartevent';
 | 
			
		||||
import * as smartfile from 'smartfile';
 | 
			
		||||
import * as smartstream from 'smartstream';
 | 
			
		||||
import * as lodash from 'lodash';
 | 
			
		||||
import * as through2 from 'through2';
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
  lodash,
 | 
			
		||||
  smartevent,
 | 
			
		||||
  smartfile,
 | 
			
		||||
  smartstream,
 | 
			
		||||
  through2
 | 
			
		||||
}
 | 
			
		||||
export { lodash, smartevent, smartfile, smartstream, through2 };
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user