How to use the upath.trimExt 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 ark120202 / babel-lua / packages / babel-lua-module-resolver / src / index.js View on Github external
let result;
      // TODO: Check if there's a better way to check if resolved path is a module
      const isModule = request.descriptionFileRoot !== this.localDescriptionFileRoot;
      // Array.from(resolveContext.stack).some(x => x.startsWith('module: '));

      if (isModule) {
        const relative = path.relative(path.dirname(request.descriptionFileRoot), request.path);
        result = `node_modules/${relative}`;
      } else {
        result = path.relative(this.luaRoot, request.path);
        if (result.startsWith('..') || path.isAbsolute(result)) {
          throw new Error(`Couldn't resolve path "${request.path}" within luaRoot`);
        }
      }

      result = path.toUnix(path.trimExt(result));

      if (result.includes('.')) {
        throw new Error(`Resolved path shouldn't contain dots`);
      }

      result = result.replace(/\//g, '.');
      request.path = result;
      return request;
    });
  }
github aurelia / webpack-plugin / dist / resolve-template.js View on Github external
function getPathWithoutExtension(input) {
  return path.trimExt(input);
}
github aurelia / webpack-plugin / src / resolve-template.js View on Github external
function getPathWithoutExtension(input) {
  return path.trimExt(input);
}

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