UNPKG

laravel-mix-glob

Version:

Laravel mix extension that add support for globs usage with an extensive concise api. For a more natural boosted productivity and dynamic. Configure once and forget about adding the files each time.

3 lines (2 loc) 1.86 kB
"use strict";var o=require("../../OutManager/index.js"),e=require("../../../Glob/Glob.js"),s=require("../../../Glob/globResolve/index.js"),i=require("../../../Glob/OutConfig/index.js"),a=require("../../../Utils/CartisianProductLoop/index.js"),l=require("../../../Utils/Logger/index.js"),t=require("./EvaluationValidation/index.js");exports.ArgSrcGlobsProcessor=class{_globsEvaluations=[];_outManagerRef;_isEvaluationsValid=!0;getGlobsEvaluations(){return this._globsEvaluations}isEvaluationsValid(){return this._isEvaluationsValid}_resolveGlobsArguments(o){this._globsEvaluations=[],this._outManagerRef=void 0,o.forEach(((o,a)=>{if(o instanceof e.Glob&&[e.EGlobType.src,e.EGlobType.arg].includes(o.type)){const i={glob:o,argIndex:a,files:[],evaluations:[]};return this._globsEvaluations.push(i),i.files=s.globResolve(i.glob.value),i.evaluations=i.files,0===i.files.length?(l.LOGGER.log(`No matched files for the Glob of arg of index ${a}`),console.log("NO MATCHED /////////"),void console.log(process.env.DEBUG)):void(o.type===e.EGlobType.arg&&i.glob.options?.map&&(i.evaluations=i.files.map(i.glob.options.map)))}o instanceof i.OutConfig&&(this._outManagerRef={outConfig:o,argIndex:a})}))}process(s,i,n){if(this._resolveGlobsArguments(s),this._globsEvaluations&&this._globsEvaluations.length>0){if(!t.checkAllEvaluationsAreValid(this._globsEvaluations))return l.LOGGER.debug("EVALUATION NOT VALID: skip execution!"),void(this._isEvaluationsValid=!1);const r=a.loopCartesianProduct(this._globsEvaluations.map((o=>o.evaluations)));let u=r.next();for(;!u.done;){const a=[...s];this._globsEvaluations?.forEach((({argIndex:s,glob:l},t)=>{a[s]=u.value[t],l.type===e.EGlobType.src&&this._outManagerRef&&(a[this._outManagerRef.argIndex]=o.mapSrcFile(u.value[t],i,this._outManagerRef.outConfig))})),n(...a),u=r.next()}}else n(...s)}}; //# sourceMappingURL=index.js.map