Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function tryRequire(tryPath: string) {
try {
// Require from CWD
return importCwd(tryPath);
} catch (error) {
// if we try to actually require npm we will import something that is the actual npm API
// not the plugin that we want
if (tryPath === 'npm') {
return;
}
try {
// Require from __dirname. Needed for npx and global installs
return require(tryPath);
} catch (error) {}
}
}
function ensurePostCSSOption(option) {
return typeof option === 'string' ? importCwd(option) : option
}
import importCWD from 'import-cwd';
const config = importCWD('./svelte-docs.config.js');
export default config;
async process({ code }) {
const less = importCwd('less')
let { css, map, imports } = await pify(less.render.bind(less))(code, {
...this.options,
sourceMap: this.sourceMap && {},
filename: this.id
})
for (const dep of imports) {
this.dependencies.add(dep)
}
if (map) {
map = JSON.parse(map)
map.sources = map.sources.map(source => humanlizePath(source))
}
async process({ code }) {
const stylus = importCwd('stylus')
const style = stylus(code, {
...this.options,
filename: this.id,
sourcemap: this.sourceMap && {}
})
const css = await pify(style.render.bind(style))()
const deps = style.deps()
for (const dep of deps) {
this.dependencies.add(dep)
}
return {
code: css,
map: style.sourcemap