How to use the path-browserify.extname 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 codesandbox / codesandboxer / packages / codesandboxer / src / fetchRelativeFile / getUrl.js View on Github external
export default function getUrl(
  filePath: string,
  { host, ...urlConfig }: GitInfo
) {
  let getRaw = raw[host];
  if (typeof getRaw !== 'function') {
    throw new Error(`Could not parse files from ${host}`);
  }

  let url = getRaw(filePath, urlConfig);
  let extName = path.extname(filePath);
  if (!extName) {
    return { fileType: '.js', url: `${url}.js` };
  } else {
    return { fileType: extName, url };
  }
}
github codesandbox / codesandboxer / packages / codesandboxer / src / fetchFiles / index.js View on Github external
example,
  extensions = [],
  template,
}: {
  examplePath: string,
  pkgJSON?: Package | string | Promise,
  gitInfo: GitInfo,
  importReplacements?: Array,
  dependencies?: Dependencies,
  providedFiles?: Files,
  example?: string | Promise,
  name?: string,
  extensions: string[],
  template?: 'create-react-app' | 'create-react-app-typescript' | 'vue-cli',
}) {
  let extension = path.extname(examplePath) || '.js';
  let config = ensureExtensionAndTemplate(extension, extensions, template);
  let pkg = await ensurePKGJSON(pkgJSON, importReplacements, gitInfo, config);

  let { file, deps, internalImports } = await ensureExample(
    example,
    importReplacements,
    pkg,
    examplePath,
    gitInfo,
    config
  );

  let fileName = `example${extension}`;

  let files = {
    ...templates[config.template],
github codesandbox / codesandboxer / packages / bitbucket-codesandboxer / src / utils / bitbucket.js View on Github external
async function getFile(gitInfo, filePath) {
  const apiUrl = `${apiBase(gitInfo)}/${filePath}`;
  const resp = await fetch(apiUrl);
  if (path.extname(filePath) === '.json') {
    return resp.json();
  }
  return resp.text();
}