source: trip-planner-front/node_modules/less/lib/less-node/plugin-loader.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[6a3a178]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var path_1 = tslib_1.__importDefault(require("path"));
5var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js"));
6/**
7 * Node Plugin Loader
8 */
9var PluginLoader = function (less) {
10 this.less = less;
11 this.require = function (prefix) {
12 prefix = path_1.default.dirname(prefix);
13 return function (id) {
14 var str = id.substr(0, 2);
15 if (str === '..' || str === './') {
16 return require(path_1.default.join(prefix, id));
17 }
18 else {
19 return require(id);
20 }
21 };
22 };
23};
24PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), {
25 loadPlugin: function (filename, basePath, context, environment, fileManager) {
26 var prefix = filename.slice(0, 1);
27 var explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';
28 if (!explicit) {
29 context.prefixes = ['less-plugin-', ''];
30 }
31 if (context.syncImport) {
32 return fileManager.loadFileSync(filename, basePath, context, environment);
33 }
34 return new Promise(function (fulfill, reject) {
35 fileManager.loadFile(filename, basePath, context, environment).then(function (data) {
36 try {
37 fulfill(data);
38 }
39 catch (e) {
40 console.log(e);
41 reject(e);
42 }
43 }).catch(function (err) {
44 reject(err);
45 });
46 });
47 },
48 loadPluginSync: function (filename, basePath, context, environment, fileManager) {
49 context.syncImport = true;
50 return this.loadPlugin(filename, basePath, context, environment, fileManager);
51 }
52});
53exports.default = PluginLoader;
54//# sourceMappingURL=plugin-loader.js.map
Note: See TracBrowser for help on using the repository browser.