MCPcopy
hub / github.com/less/less.js / loadInitialFileCallback

Function loadInitialFileCallback

packages/less/lib/less-browser/index.js:94–134  ·  view source on GitHub ↗
(loadedFile)

Source from the content-addressed store, hash-verified

92 }
93
94 function loadInitialFileCallback(loadedFile) {
95 const data = loadedFile.contents;
96 const path = loadedFile.filename;
97 const webInfo = loadedFile.webInfo;
98
99 const newFileInfo = {
100 currentDirectory: fileManager.getPath(path),
101 filename: path,
102 rootFilename: path,
103 rewriteUrls: instanceOptions.rewriteUrls
104 };
105
106 newFileInfo.entryPath = newFileInfo.currentDirectory;
107 newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
108
109 if (webInfo) {
110 webInfo.remaining = remaining;
111
112 const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);
113 if (!reload && css) {
114 webInfo.local = true;
115 callback(null, css, data, sheet, webInfo, path);
116 return;
117 }
118
119 }
120
121 // TODO add tests around how this behaves when reloading
122 errors.remove(path);
123
124 instanceOptions.rootFileInfo = newFileInfo;
125 less.render(data, instanceOptions, (e, result) => {
126 if (e) {
127 e.href = path;
128 callback(e);
129 } else {
130 cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);
131 callback(null, result.css, data, sheet, webInfo, path);
132 }
133 });
134 }
135
136 fileManager.loadFile(sheet.href, null, instanceOptions, environment)
137 .then(loadedFile => {

Callers 1

loadStyleSheetFunction · 0.85

Calls 1

getPathMethod · 0.65

Tested by

no test coverage detected