How to use the upath.isAbsolute 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
resolver.getHook('resolved').tap('LuaRootResolvePlugin', request => {
      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 qooxdoo / qooxdoo-compiler / source / class / qx / tool / compiler / resources / Manager.js View on Github external
const findLibrariesForResourceImpl = () => {
        var ns;
        var pos;
        
        // check for absolute path first, in windows c:/ is a valid absolute name
        if (path.isAbsolute(uri)) {
          let library = this.__analyser.getLibraries().find(lib => uri.startsWith(path.resolve(lib.getRootDir())));
          return library || null;
        }
  
        // Explicit library?
        pos = uri.indexOf(":");
        if (pos !== -1) {
          ns = uri.substring(0, pos);
          let library = this.__analyser.findLibrary(ns);
          return library || null;
        }
        
        // Non-wildcards are a direct lookup
        // check for $ and *. less pos wins
        // fix for https://github.com/qooxdoo/qooxdoo-compiler/issues/260
        var pos1 = uri.indexOf("$"); // Variable references are effectively a wildcard lookup
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / Command.js View on Github external
getUserQxPath : async function() {
      let qxpath = await this.getAppQxPath();
      return path.isAbsolute(qxpath) ? qxpath : path.resolve(qxpath);
    },
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / compiler / resources / Manager.js View on Github external
getAsset(srcPath, create) {
      let library = this.findLibraryForResource(srcPath);
      if (!library) {
        this.warn("Cannot find library for " + srcPath);
        return null;
      }


      let resourceDir = path.join(library.getRootDir(), library.getResourcePath());
      srcPath = path.relative(resourceDir, path.isAbsolute(srcPath)?srcPath:path.join(resourceDir, srcPath));
      let asset = this.__assets[library.getNamespace() + ":" + srcPath];
      if (!asset && create) {
        asset = new qx.tool.compiler.resources.Asset(library, srcPath, {
          resourcePath: "resourcePath"
        });
        this.__addAsset(asset);
      }
      return asset;
    },
github joelday / papyrus-lang / packages / papyrus-lang / src / projects / AmbientProjectLoader.ts View on Github external
private getPathRelativeToInstallPath(
        normalizedInstallPath: string,
        maybeRelativePath: string
    ) {
        const normalizedRelativePath = path.normalizeSafe(maybeRelativePath);

        if (path.isAbsolute(normalizedRelativePath)) {
            return normalizedRelativePath;
        }

        return path.resolve(
            path.join(normalizedInstallPath, maybeRelativePath)
        );
    }
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 {
github vuejs / vuepress / packages / @vuepress / shared-utils / src / toAbsolutePath.ts View on Github external
export = function toAbsolutePath (raw: string, cwd: string = process.cwd()) {
  if (path.isAbsolute(raw)) {
    return raw
  }
  return path.resolve(cwd, raw)
}

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