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B,OAAO,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;SAC7E;QAED,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,IAAI,CAC/D,UAAA,IAAI;gBACA,IAAI;oBACA,OAAO,CAAC,IAAI,CAAC,CAAC;iBACjB;gBACD,OAAO,CAAC,EAAE;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACf,MAAM,CAAC,CAAC,CAAC,CAAC;iBACb;YACL,CAAC,CACJ,CAAC,KAAK,CAAC,UAAA,GAAG;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,cAAc,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAChE,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAClF,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import path from 'path';\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Node Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n this.require = prefix => {\n prefix = path.dirname(prefix);\n return id => {\n const str = id.substr(0, 2);\n if (str === '..' || str === './') {\n return require(path.join(prefix, id));\n }\n else {\n return require(id);\n }\n };\n };\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n const prefix = filename.slice(0, 1);\n const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';\n if (!explicit) {\n context.prefixes = ['less-plugin-', ''];\n }\n\n if (context.syncImport) {\n return fileManager.loadFileSync(filename, basePath, context, environment);\n }\n\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment).then(\n data => {\n try {\n fulfill(data);\n }\n catch (e) {\n console.log(e);\n reject(e);\n }\n }\n ).catch(err => {\n reject(err);\n });\n });\n },\n\n loadPluginSync(filename, basePath, context, environment, fileManager) {\n context.syncImport = true;\n return this.loadPlugin(filename, basePath, context, environment, fileManager);\n }\n});\n\nexport default PluginLoader;\n\n"]}
|