How to use path-browserify - 10 common examples

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 luckymarmot / API-Flow / src / parsers / raml / v0.8 / __tests__ / generated / generate.js View on Github external
}).then(data => {
    const _content = JSON.stringify(data, null, '  ')
        /* eslint-disable no-console */
    console.log('file', file.replace(/\.[yr]a?ml$/, '.json'))
        /* eslint-enable no-console */
    fs.writeFileSync(
            path.join(generatedPath, file.replace(/\.[yr]a?ml$/, '.json')),
            _content
        )
  })
}
github expo / expo / packages / expo-asset / src / AssetSources.ts View on Github external
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
  // explicitly provided URIs
  const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
  const index = meta.scales.findIndex(s => s === scale);
  const hash = meta.fileHashes ? meta.fileHashes[index] || meta.fileHashes[0] : meta.hash;

  // Allow asset processors to directly provide the URL to load
  const uri = meta.fileUris ? meta.fileUris[index] || meta.fileUris[0] : meta.uri;
  if (uri) {
    return { uri: resolveUri(uri), hash };
  }

  // Check if the assetUrl was overridden in the manifest
  const assetUrlOverride = Constants.manifest && Constants.manifest.assetUrlOverride;
  if (assetUrlOverride) {
    const uri = path.join(assetUrlOverride, hash);
    return { uri: resolveUri(uri), hash };
  }

  const fileScale = scale === 1 ? '' : `@${scale}x`;
  const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';
  const suffix = `/${encodeURIComponent(
    meta.name
  )}${fileScale}${fileExtension}?platform=${encodeURIComponent(
    Platform.OS
  )}&hash=${encodeURIComponent(meta.hash)}`;

  // For assets with a specified absolute URL, we use the existing origin instead of prepending the
  // development server or production CDN URL origin
  if (/^https?:\/\//.test(meta.httpServerLocation)) {
    const uri = meta.httpServerLocation + suffix;
    return { uri, hash };
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 elastic / kibana / src / testUtils / istanbul_reporter / reporter.js View on Github external
.groupBy(function (file) {
    var dir = path.dirname(file.filename);
    return dir === '.' ? '' : dir;
  })
  .transform(function (dirs, files, dirname) {
github elastic / kibana / src / testUtils / istanbul_reporter / reporter.js View on Github external
_.each(files, function (file) {
      file.relname = dirname ? path.relative(dirname, file.filename) : file.filename;
    });
github Nike-Inc / referee / packages / client / src / services / DocsService.ts View on Github external
renderer.image = function(src, title, alt) {
  const curPath = window.location.pathname.replace(/(.*\/).*/, '$1');
  const subbedPath = curPath.replace('docs', 'static/docs');
  const resolvedSrc = path.resolve(subbedPath, src);
  const finalSrc = window.location.origin + resolvedSrc;
  log.debug(
    `src: ${src}, curPath: ${curPath}, subbedPath: ${subbedPath}, resolvedSrc: ${resolvedSrc} \nResolved image to load: ${finalSrc}`
  );
  console.log(title);
  let res = '
github sourcegraph / sourcegraph-basic-code-intel / languages.ts View on Github external
return imports.some(i =>
                        relativeImportToPath(i)
                            ? path.join(
                                  path.dirname(filePath),
                                  relativeImportToPath(i)
                              ) === result.file.replace(/\.[^/.]+$/, '')
                            : result.file.includes(i.replace(/\./g, '/'))
                    )
github odota / underlords-web / src / components / HomePage / HomePage.tsx View on Github external
public render() {
        return <div>
            <header>
                <h1>{ strings.app_name }</h1>
                <h3>{ strings.app_description }</h3>
                <p>{strings.home_description}</p>
                <a href="//opendota.com">{strings.home_description2}</a>
            </header>
            <main>
                <section>
                    
                         {
                            return {
                                alt: e,
                                url: `${process.env.PUBLIC_URL}/images/alliances/${e}.png`
                            };
                        })}/&gt;
                        <h4>{underlordsLoc["dac_ingame_tab_synergies"]}</h4>
                    
                    
                         {
                            const hero = heroes[e as keyof typeof heroes];
                            return {
                                alt: hero.dota_unit_name,
                                url: GetHeroImage(hero.dota_unit_name)
                            };
                        })}/&gt;</section></main></div>