Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve, reject) => {
const sass = importCwd.silent('node-sass') || importCwd.silent('sass')
if (!sass) {
throw new Error(
`You need to install either node-sass or sass in order to process Sass files`
)
}
const render = pify(sass.render.bind(sass))
return workQueue.add(() =>
render({
...this.options,
file: this.id,
data: `@import "${injectFile.replace(/\\/g, '\\\\')}";` + code,
indentedSyntax: /\.sass$/.test(this.id),
sourceMap: this.sourceMap,
importer: [
(url, importer, done) => {
if (!moduleRe.test(url)) return done({ file: url })
return new Promise((resolve, reject) => {
const sass = importCwd.silent('node-sass') || importCwd.silent('sass')
if (!sass) {
throw new Error(`You need to install either node-sass or sass in order to process Sass files`)
}
const render = pify(sass.render.bind(sass))
return workQueue.add(() =>
render({
...this.options,
file: this.id,
data: code,
indentedSyntax: /\.sass$/.test(this.id),
sourceMap: this.sourceMap,
importer: [
(url, importer, done) => {
if (!moduleRe.test(url)) return done({ file: url })
const moduleUrl = url.slice(1)
const safeGetModule = name => {
let found = importCwd.silent(name);
if (!found) {
try {
found = require(name);
} catch (err) {
found = null;
}
}
return found;
};
function tryRequire(name) {
const found = importCwd.silent(name);
if (!found) {
return require(`${name}`);
}
return found;
}
const safeGetModule = name => {
let found = importCwd.silent(name);
if (!found) {
try {
found = require(name);
} catch (err) {
found = null;
}
}
return found;
};