Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* .set(setting, value)
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#setsetting-value
*/
stylus(str)
.set('filename', __dirname + '/test.styl')
.set('paths', [__dirname, __dirname + '/mixins'])
.render(function (err, css) {
// logic
});
/**
* .include(path)
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#includepath
*/
stylus(str)
.include(require('nib').path)
.include(process.env.HOME + '/mixins')
.render(function (err, css) {
// logic
});
/**
* .import(path)
* https://github.com/LearnBoost/stylus/blob/master/docs/js.md#importpath
*/
stylus(str)
.set('filename', __dirname + '/test.styl')
.import('mixins/vendor')
.render(function (err, css) {
if (err) throw err;
console.log(css);
});
.set('compress', minimize);
if (!stylusImages.plugin) {
compiler.use(stylusImages(options.images));
}
compiler
.use(pathScopes(msg))
.include(lookupPath);
if (styleRoot) {
compiler.include(styleRoot);
}
if (useNib) {
compiler
.include(nib.path)
.use(nib);
}
// Allow any plugins to do their thing
_.each(plugins, function(plugin) {
var data = plugin.data;
plugin = require(plugin.plugin);
plugin(compiler, data);
});
try {
compiler.render(function(err, data) {
var inputs = compiler.options._imports
.concat(compiler.options.externals)
.map(function(file) { return file.path || file; })
Console.prototype.stylusSetFileImports = function(file, imports) {
var nibpath;
if (!imports) {
return delete this.imports[file];
}
nibpath = require("nib").path;
return this.imports[file] = _.compact(_.map(imports, (function(_this) {
return function(item) {
var furl, name, path, url;
if (item.path === STYLUS_FUNC_FILE) {
return;
}
path = item.path;
url = _this.pathToUrl(path);
file = _this.files.find(function(f) {
return f.srcpath === path;
});
if (!file) {
furl = 0 === path.indexOf(nibpath) ? path.slice(nibpath.length + 1) : Math.random() * 1e6 | 0;
name = _.last(path.split(/[\\\/]/));
fs.stat(path, function(err, stat) {
return _this.files.create({
function compile(str, path) {
return stylus(str)
.set('filename', path)
.include(nib.path)
}
Router.prototype.serveStylus = function(req, res) {
var path = null
, stylusContent = null
path = req.path.replace('/css/compiled', '/stylus').replace('.css', '.styl')
path = __dirname + '/..' + path.replace(this.options.endpoint, '')
stylusContent = fs.readFileSync(path).toString()
stylus(stylusContent)
.include(require('nib').path)
.render(function(err, css) {
if (err) {
throw err
}
res.type('text/css')
res.send(css)
res.send(200)
})
}
fs.readFile(inFilename, { encoding: 'utf8' }, function (err, source) {
if (err) return cb(err)
stylus(source, { filename: inFilename })
.include(nib.path)
.define('cdnOrigin', config.cdnOrigin)
.set('compress', config.isProd)
.render(function (err, css) {
if (err) return cb(err)
fs.writeFile(outFilename, css, cb)
})
})
}
function compile(str, path) {
return stylus(str)
.set('filename', path)
.include(nib.path);
}
function compileStylus (str, path) {
return stylus(str)
.set('filename', path)
.include(nib.path)
}