How to use the upath.resolve 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 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 cksource / mrgit / tests / utils / getoptions.js View on Github external
it( 'does not fail if mrgit.json is not defined ', () => {
			const cwd = path.resolve( __dirname, '..', 'fixtures', 'project-with-no-mrgitjson' );
			const options = getOptions( {}, cwd );

			expect( options ).to.deep.equal( {
				cwd,
				packages: path.resolve( cwd, 'packages' ),
				resolverPath: path.resolve( __dirname, '../../lib/default-resolver.js' ),
				resolverUrlTemplate: 'git@github.com:${ path }.git',
				resolverTargetDirectory: 'git',
				resolverDefaultBranch: 'master',
				scope: null,
				ignore: null,
				packagesPrefix: [],
				overrideDirectoryNames: {},
				baseBranches: []
			} );
		} );
github cksource / mrgit / tests / utils / getoptions.js View on Github external
it( 'priorities passed options', () => {
			const cwd = path.resolve( __dirname, '..', 'fixtures', 'project-with-options-in-mrgitjson' );
			const options = getOptions( {
				resolverUrlTemplate: 'a/b/c',
				packages: 'bar'
			}, cwd );

			expect( options ).to.deep.equal( {
				dependencies: {
					'simple-package': 'a/b'
				},
				cwd,
				packages: path.resolve( cwd, 'bar' ),
				resolverPath: path.resolve( __dirname, '../../lib/default-resolver.js' ),
				resolverUrlTemplate: 'a/b/c',
				resolverTargetDirectory: 'git',
				resolverDefaultBranch: 'master',
				scope: null,
				ignore: null,
				packagesPrefix: [],
				overrideDirectoryNames: {},
				baseBranches: []
			} );
		} );
github aurelia / webpack-plugin / dist / resolve-template.js View on Github external
webpackPath = getPath(moduleName, isLazy, bundleName);
              webpackRequireString = './' + fromPath;
            } else if (stats.isFile()) {
              moduleName = fromPath.split(pathSep)[0];
              modulePath = path.resolve(nodeModulesList[nodeModulesIndex], moduleName);

              webpackPath = getPath(fullPath, isLazy, bundleName);
              webpackRequireString = './' + fromPath;
            }

            if (!(moduleName && modulePath)) {
              _context5.next = 99;
              break;
            }

            packageJson = path.resolve(modulePath, 'package.json');
            vendorPkg = void 0;

            try {
              vendorPkg = JSON.parse(fileSystem.readFileSync(packageJson, 'utf8'));
            } catch (_) {}

            if (!vendorPkg) {
              _context5.next = 97;
              break;
            }

            mainDir = vendorPkg.main ? path.resolve(modulePath, path.dirname(vendorPkg.main)) : null;


            if (!rootAlias) {
              if (vendorPkg.aurelia && vendorPkg.aurelia.build && vendorPkg.aurelia.build.root) {
github aurelia / webpack-plugin / dist / build-resources.js View on Github external
}).map(function (dir) {
    return path.resolve(moduleDir, dir);
  });
github aurelia / webpack-plugin / dist / resolve-template.js View on Github external
return _context.abrupt('break', 39);

          case 24:
            _ref = _i.value;

          case 25:
            moduleName = _ref;

            if (!(modulesProcessed.indexOf(moduleName) === -1)) {
              _context.next = 37;
              break;
            }

            modulesProcessed.push(moduleName);
            vendorPath = path.resolve(options.root, 'node_modules', moduleName);
            vendorPkgPath = path.resolve(vendorPath, 'package.json');
            vendorPkg = JSON.parse(fileSystem.readFileSync(vendorPkgPath, 'utf8'));

            if (!(vendorPkg.browser || vendorPkg.main)) {
              _context.next = 37;
              break;
            }

            _context.t2 = dependencies;
            _context.next = 35;
            return getDependency(moduleName, options.root, options.root, [nodeModules], null, packageJson, options.lazy, options.bundle, undefined, undefined, true);

          case 35:
            _context.t3 = _context.sent;
            assign(_context.t2, _context.t3);

          case 37:
github TimboKZ / Rammy / lib / Constants.js View on Github external
Template: 'template',
    Snippet: 'snippet',
};

module.exports = {
    ConfigFileName: '.rammyrc.json',
    ComponentNameRegex: /^([a-z0-9\-_]+\/)?[a-z0-9\-_]+$/i,
    ComponentType,
    RammyRegion: {
        Start: '%-- Rammy start',
        StartFull: '%-- Rammy start ----------------',
        End: '%-- Rammy end',
        EndFull: '%-- Rammy end ------------------',

    },
    TexIgnorePath: upath.resolve(__dirname, '../assets/TeX.gitignore'),
    AuxExtensions: [
        '.aux',
        '.lof',
        '.log',
        '.lot',
        '.fls',
        '.out',
        '.toc',
        '.fmt',
        '.fot',
        '.cb',
        '.cb2',
        '.bbl',
        '.bcf',
        '.blg',
        '-blx.aux',
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 aurelia / webpack-plugin / dist / resolve-template.js View on Github external
try {
              vendorPkg = JSON.parse(fileSystem.readFileSync(packageJson, 'utf8'));
            } catch (_) {}

            if (!vendorPkg) {
              _context5.next = 97;
              break;
            }

            mainDir = vendorPkg.main ? path.resolve(modulePath, path.dirname(vendorPkg.main)) : null;


            if (!rootAlias) {
              if (vendorPkg.aurelia && vendorPkg.aurelia.build && vendorPkg.aurelia.build.root) {
                rootAlias = path.resolve(modulePath, vendorPkg.aurelia.build.root);
              } else if (baseVendorPkg && baseVendorPkg.aurelia && baseVendorPkg.aurelia.build && baseVendorPkg.aurelia.build.moduleRootOverride && baseVendorPkg.aurelia.build.moduleRootOverride[moduleName]) {
                rootAlias = path.resolve(srcPath, baseVendorPkg.aurelia.build.moduleRootOverride[moduleName]);
              } else {
                rootAlias = mainDir;
              }

              if (rootAlias === modulePath) rootAlias = null;
            }

            if (doNotAdd) {
              _context5.next = 60;
              break;
            }

            _context5.next = 60;
            return addDependency(webpackRequireString, webpackPath, htmlCounterpart, rootAlias, moduleName, modulePath);

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