How to use the import-cwd 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 intuit / auto / packages / core / src / utils / try-require.ts View on Github external
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) {}
  }
}
github egoist / rollup-plugin-postcss / src / postcss-loader.js View on Github external
function ensurePostCSSOption(option) {
  return typeof option === 'string' ? importCwd(option) : option
}
github AlexxNB / svelte-docs / packages / core / config.js View on Github external
import importCWD from 'import-cwd';

const config = importCWD('./svelte-docs.config.js');

export default config;
github egoist / rollup-plugin-postcss / src / less-loader.js View on Github external
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))
    }
github egoist / rollup-plugin-postcss / src / stylus-loader.js View on Github external
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

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