How to use the upath.parse function in upath

To help you get started, we’ve selected a few upath 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 GoogleChrome / workbox / packages / workbox-build / src / options / schema / webpack-inject-manifest.js View on Github external
const swSrcBasename = (context) => {
  const {name} = upath.parse(context.swSrc);
  // Always use the .js extension when generating a default filename.
  return name + '.js';
};
swSrcBasename.description = 'derived from the swSrc file name';
github GoogleChrome / workbox / packages / workbox-build / src / lib / bundle.js View on Github external
module.exports = async ({
  babelPresetEnvTargets,
  inlineWorkboxRuntime,
  mode,
  sourcemap,
  swDest,
  unbundledCode,
}) => {
  // We need to write this to the "real" file system, as Rollup won't read from
  // a custom file system.
  const {dir, base} = upath.parse(swDest);

  const temporaryFile = tempy.file({name: base});
  await writeFile(temporaryFile, unbundledCode);

  const plugins = [
    resolve(),
    replace({'process.env.NODE_ENV': JSON.stringify(mode)}),
    babel({
      // Disable the logic that checks for local Babel config files:
      // https://github.com/GoogleChrome/workbox/issues/2111
      babelrc: false,
      configFile: false,
      presets: [[presetEnv, {
        targets: {
          browsers: babelPresetEnvTargets,
        },
github vuejs / vuepress / packages / @vuepress / shared-utils / src / moduleResolver.ts View on Github external
resolvePathPackage (req: string) {
    if (!path.isAbsolute(req)) {
      req = path.resolve(this.cwd, req)
    }

    const normalized = fsExistsFallback([
      req,
      req + '.js',
      path.resolve(req, 'index.js')
    ])

    if (!normalized) {
      throw new Error(`${req} Not Found.`)
    }

    const dirname = path.parse(normalized).name
    const { shortcut, name } = this.normalizeName(dirname)
    try {
      const module = this.load ? require(normalized) : normalized
      return new CommonModule(module, name, shortcut, false /* fromDep */)
    } catch (error) {
      return getNoopModule(error)
    }
  }
github hmrc / assets-frontend / gulpfile.js / util / design-system / lib / renderPagesFromTemplate.js View on Github external
.map((file) => ({
          url: relativeUrl(baseDirectory, file.relative),
          title: upath.parse(upath.parse(file.relative).dir).name
        }))
github ryanelian / instapack / src / Shout.ts View on Github external
fileOutput(filePath: string, content: string): Promise {
        const bundle = Buffer.from(content, 'utf8');
        const info = upath.parse(filePath);
        const size = prettyBytes(bundle.byteLength);

        Shout.timed(chalk.blue(info.base), chalk.magenta(size), chalk.grey('in ' + info.dir + '/'));
        return fse.outputFile(filePath, bundle);
    }
};
github willmendesneto / update-yeoman-generator / lib / util.js View on Github external
removeFilesInDirectory: filePath => {
    fs.unlinkSync(filePath);
    let folder = upath.dirname(filePath);
    while (fs.readdirSync(folder).length === 0) {
      fs.rmdirSync(folder);
      folder = upath.parse(folder).dir;
    }
  },
github ryanelian / instapack / bin / Shout.js View on Github external
fileOutput(filePath, content) {
        const bundle = Buffer.from(content, 'utf8');
        const info = upath.parse(filePath);
        const size = PrettyUnits_1.prettyBytes(bundle.byteLength);
        exports.Shout.timed(chalk.blue(info.base), chalk.magenta(size), chalk.grey('in ' + info.dir + '/'));
        return fse.outputFile(filePath, bundle);
    }
};
github jus / jus / lib / file.js View on Github external
var targetExt = this.path.ext.toLowerCase()
    if (this.type === 'page') targetExt = '.html'
    if (this.type === 'script') targetExt = '.js'
    if (this.type === 'stylesheet') targetExt = '.css'

    var targetFull = this.path.full
      .replace(sourceDir, targetDir)
      .replace(this.path.ext, targetExt)

    this.path.target = {
      full: targetFull,
      relative: targetFull.replace(targetDir, '')
    }

    Object.assign(this.path.target, path.parse(this.path.target.relative))
  }
github TimboKZ / Rammy / lib / TexFileManager.js View on Github external
.then(() => {
                const pathData = path.parse(data.filePath);
                Util.verify(pathData.ext === '.tex', `'${pathData.base}' isn't a TeX file!`);

                const count = Constants.AuxExtensions.length;
                const promises = new Array(count);
                for (let i = 0; i < count; i++) {
                    const ext = Constants.AuxExtensions[i];
                    const filePath = path.join(pathData.dir, `${pathData.name}${ext}`);
                    promises[i] = Promise.resolve()
                        .then(() => fs.pathExists(filePath))
                        .then(fileExists => fileExists ? fs.unlink(filePath) : null);
                }

                return Promise.all(promises);
            });
    }

upath

A proxy to `path`, replacing `\` with `/` for all results (supports UNC paths) & new methods to normalize & join keeping leading `./` and add, change, default, trim file extensions.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis