Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var stylusFile = function(context, path) {
// Stylus adds .styl to paths for normal "paths" lookup if it isn't there.
if (!/.styl$/.test(path)) {
path += '.styl';
}
var paths = options.paths.concat(context);
var found = utils.find(path, paths, options.filename)
if (found) {
return normalizePaths(found);
}
};
return imported
}
// Literal
if (/\.css(?:"|$)/.test(path)) {
literal = true
if (!imported.once && !this.includeCSS) {
return imported
}
}
// support optional .styl
if (!literal && !/\.styl$/i.test(path)) path += ".styl"
// Lookup
found = utils.find(path, this.paths, this.filename)
if (!found) {
found = utils.lookupIndex(name, this.paths, this.filename)
}
/*****************************************************************************
* THIS IS THE ONLY BLOCK THAT DIFFERS FROM THE ACTUAL STYLUS IMPLEMENTATION. *
*****************************************************************************/
// if still not found, so maybe it ref to a module file in node_modules
if (!found) {
path = urlToRequest(path)
let pathComponents = this.filename.split(sep)
if (pathComponents.indexOf("components") > -1) {
const pkgDir = pathComponents
.slice(0, pathComponents.indexOf("components") + 2)
.join(sep)
found = [resolve.sync(path, { extensions: [".styl"], basedir: pkgDir })]
}
return imported;
}
}
// support optional .styl
if (!literal && !/\.styl$/i.test(path)) path += '.styl';
/*****************************************************************************
* THIS IS THE ONLY BLOCK THAT DIFFERS FROM THE ACTUAL STYLUS IMPLEMENTATION. *
*****************************************************************************/
// Lookup
var dirname = this.paths[this.paths.length - 1];
found = this.cache.find(path, dirname);
index = this.cache.isIndex(path, dirname);
if (!found) {
found = utils.find(path, this.paths, this.filename);
if (!found) {
found = utils.lookupIndex(name, this.paths, this.filename);
index = true;
}
}
// Throw if import failed
if (!found) throw new Error('failed to locate @' + nodeName + ' file ' + path);
var block = new nodes.Block;
for (var i = 0, len = found.length; i < len; ++i) {
block.push(importFile.call(this, imported, found[i], literal, index));
}
return block;
function(context, path) {
// Stylus adds .styl to paths for normal "paths" lookup if it isn't there.
if (!/.styl$/.test(path)) {
path += '.styl';
}
var found = utils.find(path, options.paths, options.filename)
if (found) {
return normalizePaths(found);
}
},
// Stylus's normal resolver for node_modules packages. Cannot locate paths