lib/extends/_filesToStream.js
function _readContent (files, writeStream, separator) {

			return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {

				const file = files.shift().trim();

				return isFileProm(file).then((exists) => {

					const isPattern = -1 < separator.indexOf("{{filename}}");

					return !exists ? _readContent(files, writeStream, separator) : Promise.resolve().then(() => {

						return !isPattern ? Promise.resolve() : new Promise((resolve, reject) => {

							writeStream.write(separator.replace("{{filename}}", basename(file)), (err) => {
								return err ? reject(err) : resolve();
							});

						});

					}).then(() => {

						return new Promise((resolve, reject) => {

							const readStream = createReadStream(file);
							let error = false;

							readStream.once("error", (err) => {

								error = true;

								readStream.close();
								reject(err);

							}).once("open", () => {
								readStream.pipe(writeStream, { "end": false });
							}).once("close", () => {

								if (!error) {
									resolve();
								}

							});

						});

					}).then(() => {

						return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {

							return isPattern ? Promise.resolve() : new Promise((resolve, reject) => {

								writeStream.write(separator, (err) => {
									return err ? reject(err) : resolve();
								});

							});

						}).then(() => {
							return _readContent(files, writeStream, separator);
						});

					});

				});

			});

		}
function _readContent (files, writeStream, separator) {

			return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {

				const file = files.shift().trim();

				return isFileProm(file).then((exists) => {

					const isPattern = -1 < separator.indexOf("{{filename}}");

					return !exists ? _readContent(files, writeStream, separator) : Promise.resolve().then(() => {

						return !isPattern ? Promise.resolve() : new Promise((resolve, reject) => {

							writeStream.write(separator.replace("{{filename}}", basename(file)), (err) => {
								return err ? reject(err) : resolve();
							});

						});

					}).then(() => {

						return new Promise((resolve, reject) => {

							const readStream = createReadStream(file);
							let error = false;

							readStream.once("error", (err) => {

								error = true;

								readStream.close();
								reject(err);

							}).once("open", () => {
								readStream.pipe(writeStream, { "end": false });
							}).once("close", () => {

								if (!error) {
									resolve();
								}

							});

						});

					}).then(() => {

						return 0 >= files.length ? Promise.resolve() : Promise.resolve().then(() => {

							return isPattern ? Promise.resolve() : new Promise((resolve, reject) => {

								writeStream.write(separator, (err) => {
									return err ? reject(err) : resolve();
								});

							});

						}).then(() => {
							return _readContent(files, writeStream, separator);
						});

					});

				});

			});

		}
function _readContent ( files , writeStream , separator ) { return 0 >= files . length ? Promise . resolve ( ) : Promise . resolve ( ) . then ( ( ) => { const file = files . shift ( ) . trim ( ) ; return isFileProm ( file ) . then ( ( exists ) => { const isPattern = - 1 < separator . indexOf ( "{{filename}}" ) ; return ! exists ? _readContent ( files , writeStream , separator ) : Promise . resolve ( ) . then ( ( ) => { return ! isPattern ? Promise . resolve ( ) : new Promise ( ( resolve , reject ) => { writeStream . write ( separator . replace ( "{{filename}}" , basename ( file ) ) , ( err ) => { return err ? reject ( err ) : resolve ( ) ; } ) ; } ) ; } ) . then ( ( ) => { return new Promise ( ( resolve , reject ) => { const readStream = createReadStream ( file ) ; let error = false ; readStream . once ( "error" , ( err ) => { error = true ; readStream . close ( ) ; reject ( err ) ; } ) . once ( "open" , ( ) => { readStream . pipe ( writeStream , { "end" : false } ) ; } ) . once ( "close" , ( ) => { if ( ! error ) { resolve ( ) ; } } ) ; } ) ; } ) . then ( ( ) => { return 0 >= files . length ? Promise . resolve ( ) : Promise . resolve ( ) . then ( ( ) => { return isPattern ? Promise . resolve ( ) : new Promise ( ( resolve , reject ) => { writeStream . write ( separator , ( err ) => { return err ? reject ( err ) : resolve ( ) ; } ) ; } ) ; } ) . then ( ( ) => { return _readContent ( files , writeStream , separator ) ; } ) ; } ) ; } ) ; } ) ; }
methods 
Specific to "filesToString" method, read all files content
@param {Array} files : files to read
@param {stream.Transform} writeStream : stream to send data
@param {string} separator : used to separate content (can be "")
@returns {Promise} Operation's result
methods Specific to filesToString method read all files content