How to use the path-browserify.dirname function in path-browserify

To help you get started, we’ve selected a few path-browserify 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 sourcegraph / sourcegraph-basic-code-intel / languages.ts View on Github external
filterDefinitions: ({ repo, filePath, fileContent, results }) => {
                const currentFileImportedPaths = fileContent
                    .split(/\r?\n/)
                    .map(line => {
                        // Matches the import at index 3
                        const match = /^(import |\t)(\w+ |\. )?"(.*)"$/.exec(
                            line
                        )
                        return match ? match[3] : undefined
                    })
                    .filter((x): x is string => Boolean(x))

                const currentFileImportPath =
                    repo + '/' + path.dirname(filePath)

                const filteredResults = results.filter(result => {
                    const resultImportPath =
                        result.repo + '/' + path.dirname(result.file)
                    return [
                        ...currentFileImportedPaths,
                        currentFileImportPath,
                    ].some(i => resultImportPath === i)
                })

                return filteredResults.length === 0 ? results : filteredResults
            },
        },
github codesandbox / codesandboxer / packages / bitbucket-codesandboxer / src / utils / bitbucket.js View on Github external
async function gitPkgUp(gitInfo, filePath) {
  // Return true if a list of file paths contains a package.json file
  const filesContainPkgJson = files =>
    files.some(file => path.basename(file.path) === 'package.json');
  let curPath = path.dirname(filePath);
  let filesInDir = await getBitbucketDir(gitInfo, curPath);
  while (!filesContainPkgJson(filesInDir) && curPath !== '.') {
    curPath = path.dirname(curPath);
    filesInDir = await getBitbucketDir(gitInfo, curPath);
  }
  if (!filesContainPkgJson(filesInDir)) {
    throw new Error('Unable to find a package.json');
  }
  return path.join(curPath, 'package.json').replace('./', '');
}
github codesandbox / codesandboxer / packages / bitbucket-codesandboxer / src / utils / bitbucket.js View on Github external
async function gitPkgUp(gitInfo, filePath) {
  // Return true if a list of file paths contains a package.json file
  const filesContainPkgJson = files =>
    files.some(file => path.basename(file.path) === 'package.json');
  let curPath = path.dirname(filePath);
  let filesInDir = await getBitbucketDir(gitInfo, curPath);
  while (!filesContainPkgJson(filesInDir) && curPath !== '.') {
    curPath = path.dirname(curPath);
    filesInDir = await getBitbucketDir(gitInfo, curPath);
  }
  if (!filesContainPkgJson(filesInDir)) {
    throw new Error('Unable to find a package.json');
  }
  return path.join(curPath, 'package.json').replace('./', '');
}
github chemzqm / stack-source-map / index.js View on Github external
function supportRelativeURL(file, url) {
  if (!file) return url;
  var dir = path.dirname(file);
  var match = /^\w+:\/\/[^\/]*/.exec(dir);
  var protocol = match ? match[0] : '';
  return protocol + path.resolve(dir.slice(protocol.length), url);
}
github sourcegraph / sourcegraph-basic-code-intel / languages.ts View on Github external
const filteredResults = results.filter(result => {
                    const resultImportPath =
                        result.repo + '/' + path.dirname(result.file)
                    return [
                        ...currentFileImportedPaths,
                        currentFileImportPath,
                    ].some(i => resultImportPath === i)
                })
github sourcegraph / sourcegraph-basic-code-intel / languages.ts View on Github external
return [...currentFileImports, currentPackage].some(i =>
                        path
                            .dirname(result.file)
                            .replace(/\//g, '.')
                            .endsWith(i)
                    )