How to use replace-ext - 7 common examples

To help you get started, we’ve selected a few replace-ext 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 tinajs / mina-webpack / packages / mina-entry-webpack-plugin / src / loaders / virtual-mina-loader.ts View on Github external
let findFileWithExtname = (extname: string) => {
      let filePath = replaceExt(this.resourcePath, `.${extname}`)
      // @ts-ignore
      return fs.exists(filePath).then(isExist => ({ isExist, filePath }))
    }
    return pAny(extnames.map(findFileWithExtname), {
github tinajs / mina-webpack / packages / mina-loader / src / loaders / mina.ts View on Github external
new Error(
        'The api `translations` of mina-loader is deprecated. Please use `transform` instead.'
      )
    )
  }

  const originalRequest = loaderUtils.getRemainingRequest(this)
  const filePath = this.resourcePath

  let relativePath = path.relative(this.rootContext, filePath)

  // move some files into subpackages
  // .js files are moved in entry plugin but .json/.wxss/.wxml should be handled here
  // @ts-ignore
  const subpackageMapping: Record = this.subpackageMapping || {}
  const entryName = replaceExt(helpers.toSafeOutputPath(relativePath), '')
  if (subpackageMapping[entryName]) {
    relativePath = subpackageMapping[entryName] + '.mina'
  }

  const dirname = compose(
    ensurePosix,
    helpers.toSafeOutputPath,
    path.dirname
  )(relativePath)

  getBlocks(this, originalRequest)
    .then(blocks =>
      Promise.all(
        [...TAGS_FOR_FILE_LOADER, ...TAGS_FOR_OUTPUT].map(async (tag: Tag) => {
          let result: BlockResult = {
            tag,
github appium / appium / commands-yml / parse.js View on Github external
log(`Rendering file: ${filename} ${relativeFilename}`);

    // Translate the YML specs to JSON
    const inputYML = await fs.readFile(filename, 'utf8');
    const inputJSON = yaml.load(inputYML);
    inputJSON.ymlFileName = `/${path.relative(rootFolder, filename)}`;
    const validationErrors = validate(inputJSON, validator);
    if (validationErrors) {
      throw new Error(`Data validation error for ${filename}: ${JSON.stringify(validationErrors)}`);
    }

    // Pass the inputJS into our Handlebars template
    const markdown = template(inputJSON);

    // Write the markdown to its right place
    const markdownPath = replaceExt(relativeFilename, '.md');
    const outfile = path.resolve(rootFolder, 'docs', 'en', markdownPath);
    log(`    Writing to: ${outfile}`);
    await mkdirp(path.dirname(outfile));
    await fs.writeFile(outfile, markdown, 'utf8');

    fileCount++;
  }
  log(`Done writing ${fileCount} command documents`);
}
github tinajs / mina-webpack / packages / mina-loader / src / loaders / mina-json.ts View on Github external
function stripExt(path: string): string {
  return replaceExt(path, '')
}
github laravel / elixir / src / tasks / GulpPaths.js View on Github external
changeExtension(path, newExtension) {
        return replaceExt(path, newExtension);
    }
github tinajs / tina-router / src / utils.js View on Github external
return global.__wxConfig.tabBar.list.map(({ pagePath }) => {
    return extname(pagePath, '')
  })
}

replace-ext

Replaces a file extension with another one.

MIT
Latest version published 4 years ago

Package Health Score

68 / 100
Full package analysis

Popular replace-ext functions