import { ReplaceOptions } from '@balm-core/index' ; class ReplaceTask extends BalmJS . BalmTask { constructor ( ) { super ( 'replace' ) ; } recipe ( input , output , options ) { const balmReplace = ( ) : any => { this . init ( input , output ) ; let stream = this . src ; if ( BalmJS . utils . isArray ( options ) ) { const replaceOptions = options as ReplaceOptions [ ] ; replaceOptions . forEach ( ( replaceOption ) => { stream = stream . pipe ( BalmJS . plugins . replace ( replaceOption . substr , replaceOption . replacement ) ) ; } ) ; } else { const replaceOption = options as ReplaceOptions ; stream = stream . pipe ( BalmJS . plugins . replace ( replaceOption . substr , replaceOption . replacement ) ) ; } return stream . pipe ( gulp . dest ( this . output ) ) ; } ; return balmReplace ; } fn ( callback ) { callback ( ) ; } } export default ReplaceTask ;