How to use the find-parent-dir.sync function in find-parent-dir

To help you get started, we’ve selected a few find-parent-dir 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 typicode / husky / src / index.js View on Github external
function findHooksDir (dirname) {
  var dir = findParentDir.sync(dirname, '.git')

  if (dir) {
    var gitDir = path.join(dir, '.git')
    var stats = fs.lstatSync(gitDir)

    if (stats.isFile()) {
      // Expect following format
      // git: pathToGit
      gitDir = fs
        .readFileSync(gitDir, 'utf-8')
        .split(':')[1]
        .trim()

      return path.resolve(dir, gitDir, 'hooks')
    }
github google / clasp / index.js View on Github external
PROJECT: () => {
    let projectDirectory = findParentDir.sync(process.cwd(), DOT.PROJECT.PATH) || DOT.PROJECT.DIR;
    return dotf(projectDirectory, DOT.PROJECT.NAME);
  },
  // See `login`: Stores { accessToken, refreshToken }
github onivim / oni / vim / vimfiles / bundle / oni-plugin-typescript / lib / index.js View on Github external
require: function (requirePath) {
            try {
                var path_1 = require("path");
                // See if this is a 'node_modules' dependency:
                var modulePath = findParentDir.sync(__dirname, path_1.join("node_modules", requirePath));
                if (modulePath) {
                    requirePath = path_1.join(modulePath, "node_modules", requirePath);
                }
                return mod.require(requirePath);
            }
            catch (ex) {
                // TODO: Log require error here
                debugger; // tslint:disable-line no-debugger
            }
        },
    };
github Modernizr / Modernizr / test / node / lib / build.js View on Github external
var root = require('find-parent-dir').sync(__dirname, 'package.json');
var build = require(root + 'lib/build');
var chai = require('chai');
var expect = chai.expect;

describe('cli/build', function() {

  it('should build without error', function() {
    expect(function() {build();}).to.not.throw();
  });

  describe('custom builds', function(done) {

    it('should build without errors when using a custom build', function() {
      expect(function() {
        build({'feature-detects': ['css/boxsizing']}, done);
      }).to.not.throw();
github moon0326 / swagger-ui-watcher / bin / swagger-ui-watcher.js View on Github external
.option('-h, --host ', 'Host to be used. Default is 127.0.0.1')
    .option('-b, --bundle ', 'Create bundle and save it to bundleTo')
    .action(function(swaggerFile, targetDir) {
        swaggerFileValue = swaggerFile;
        targetDirValue = targetDir;
    })
    .parse(process.argv);

if (typeof swaggerFileValue === 'undefined') {
    console.error(` is required.\n${help}`);
    process.exit(1);
}

if (typeof targetDirValue === 'undefined') {
    try {
        targetDirValue = findParentDir.sync(path.dirname(swaggerFileValue), path.basename(swaggerFileValue));
    } catch (err) {
        console.error(`Failed to resolve [targetDir]/${swaggerFileValue}.\n${help}`);
        process.exit(1);
    }
}

if (typeof program.port === 'undefined') {
    program.port = 8000;
}

if (typeof program.host === 'undefined') {
    program.host = "127.0.0.1";
}

if (typeof program.bundle === 'undefined') {
    program.bundle = null;
github xcatliu / pagic / src / util / getLayout.js View on Github external
module.exports = function getLayout(currentPath) {
  const layoutDir = findParentDir.sync(currentPath, '_layout.js');

  if (!layoutDir) {
    return null;
  }

  const requirePath = path.resolve(layoutDir, '_layout.js');
  const layout = require(requirePath);

  delete require.cache[require.resolve(requirePath)];

  return layout;
};
github perfectsense / brightspot-styleguide / js / resolver.js View on Github external
function resolvePath (root, parent, file) {
  if (file.startsWith('/node_modules/')) {
    return path.join(root, file)
  } else if (file.startsWith('/')) {
    const packageRoot = findParentDir.sync(parent, 'package.json')

    if (packageRoot) {
      return path.join(packageRoot, file)
    } else {
      return path.join(root, file)
    }
  } else {
    return path.resolve(path.dirname(parent), file)
  }
}

find-parent-dir

Finds the first parent directory that contains a given file or directory.

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular find-parent-dir functions