How to use is-directory - 7 common examples

To help you get started, we’ve selected a few is-directory 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 sapegin / mrm / packages / mrm / bin / mrm.js View on Github external
} else {
		throw err;
	}
});

const argv = minimist(process.argv.slice(2));
const tasks = argv._;

const binaryPath = process.env._;
const binaryName =
	binaryPath && binaryPath.endsWith('/npx') ? 'npx mrm' : 'mrm';

// Custom config / tasks directory
if (argv.dir) {
	const dir = path.resolve(argv.dir);
	if (!isDirectory.sync(dir)) {
		printError(`Directory “${dir}” not found.`);
		process.exit(1);
	}

	directories.unshift(dir);
}

// Preset
const preset = argv.preset || 'default';
const isDefaultPreset = preset === 'default';
if (isDefaultPreset) {
	directories.push(path.dirname(require.resolve('mrm-preset-default')));
} else {
	const presetPath = tryResolve(`mrm-preset-${preset}`, preset);
	if (!presetPath) {
		printError(`Preset “${preset}” not found.
github runtools / run / core / src / resource / index.js View on Github external
function searchImplementationFile(file) {
  if (isDirectory.sync(file)) {
    const dir = file;
    const mainFile = join(dir, 'index.js');
    if (existsSync(mainFile)) {
      return mainFile;
    }
  } else {
    if (existsSync(file)) {
      return file;
    }
    const fileWithExtension = file + '.js';
    if (existsSync(fileWithExtension)) {
      return fileWithExtension;
    }
  }
  return undefined;
}
github fabiospampinato / template / src / utils.ts View on Github external
getPath ( name, checkExistence = false ) {

      const templatePath = path.join ( Config.directory, name );

      return checkExistence ? isDirectory.sync ( templatePath ) && templatePath : templatePath;

    },
github runtools / run / core / old / 2 / src / component.js View on Github external
static searchComponentFile(dirOrFile, {searchInPath = false} = {}) {
    let dir;

    if (isDirectory.sync(dirOrFile)) {
      dir = dirOrFile;
    } else if (existsSync(dirOrFile)) {
      const file = dirOrFile;
      const filename = basename(file);
      if (
        this.SUPPORTED_FILE_FORMATS.find(
          format => filename === this.DEFAULT_FILE_NAME + '.' + format
        )
      ) {
        return file;
      }
    }

    if (!dir) {
      return undefined;
    }
github raphamorim / elekid / index.js View on Github external
const load = function _load (path) {
  try {
    try {
      const dep = require(path)
      return dep
    } catch (err) {
      path = path.replace('./', '')
      path = `${DIRPATH}/${path}`

      if (isDirectory.sync(path)) {
        path = path + '/index.js'
      } else {
        path = path + '.js'
      }

      logger(path, true)

      let transform = babel.transformFileSync(path, babelConfig)

      transform = transform.code.replace('exports.default', 'module.exports')
      const pathElekid = (process.env.ELEKID_DEBUG) ? `${process.cwd()}/index.js` : 'elekid'
      transform = `"use strict"; require = require('${pathElekid}').load; ${transform}`
      const component = requireFromString(transform)
      return component
    }
  } catch (err) {
github runtools / run / old / tools / js / esnext-package / src / index.js View on Github external
filter: file => {
          const relativeFile = relative(srcDir, file);
          if (isDirectory.sync(file)) {
            const targetDir = join(distDir, relativeFile);
            emptyDirSync(targetDir);
            return true;
          }
          const extension = extname(file);
          if (!transpilableExtensions.includes(extension)) {
            return true;
          }
          transpilableFiles.push(relativeFile);
          return false;
        }
      });
github alice-em / wonder-reader / app / modules / File.js View on Github external
fs.readFile(this.origin, (err, data) => {
      if (!err) {
        this.data = data;
        if (isDirectory.sync(this.tempdir)) {
          rimraf.sync(this.tempdir);
        }
        mkdirp(this.tempdir, (errd) => {
          this.routeExtraction(errd, cb);
        });
      }
    });
  }

is-directory

Returns true if a filepath exists on the file system and it's directory.

MIT
Latest version published 9 years ago

Package Health Score

65 / 100
Full package analysis

Popular is-directory functions