How to use the import-cwd.silent function in import-cwd

To help you get started, we’ve selected a few import-cwd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EdgeApp / edge-login-ui / packages / edge-login-ui-react / sass-loader.js View on Github external
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 })
github egoist / rollup-plugin-postcss / src / sass-loader.js View on Github external
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)
github qlik-oss / after-work.js / plugins / preset-plugin / src / index.js View on Github external
const safeGetModule = name => {
  let found = importCwd.silent(name);
  if (!found) {
    try {
      found = require(name);
    } catch (err) {
      found = null;
    }
  }
  return found;
};
github qlik-oss / after-work.js / src / transform.js View on Github external
function tryRequire(name) {
  const found = importCwd.silent(name);
  if (!found) {
    return require(`${name}`);
  }
  return found;
}
github qlik-oss / after-work.js / packages / utils / src / index.js View on Github external
const safeGetModule = name => {
  let found = importCwd.silent(name);
  if (!found) {
    try {
      found = require(name);
    } catch (err) {
      found = null;
    }
  }
  return found;
};

import-cwd

Import a module like with `require()` but from the current working directory

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis

Popular import-cwd functions