How to use the @yarnpkg/fslib.npath.fromPortablePath function in @yarnpkg/fslib

To help you get started, we’ve selected a few @yarnpkg/fslib 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 yarnpkg / berry / packages / yarnpkg-pnp / sources / loader / makeApi.ts View on Github external
function callNativeResolution(request: PortablePath, issuer: PortablePath): NativePath | false {
    if (issuer.endsWith(`/`))
      issuer = ppath.join(issuer, toFilename(`internal.js`));

    // Since we would need to create a fake module anyway (to call _resolveLookupPath that
    // would give us the paths to give to _resolveFilename), we can as well not use
    // the {paths} option at all, since it internally makes _resolveFilename create another
    // fake module anyway.
    return Module._resolveFilename(request, makeFakeModule(npath.fromPortablePath(issuer)), false, {plugnplay: false});
  }
github yarnpkg / berry / packages / yarnpkg-core / sources / scriptUtils.ts View on Github external
for (const locatorHash of visibleLocators) {
    const dependency = project.storedPackages.get(locatorHash);
    if (!dependency)
      throw new Error(`Assertion failed: The package (${locatorHash}) should have been registered`);

    if (dependency.bin.size === 0)
      continue;

    const linker = linkers.find(linker => linker.supportsPackage(dependency, linkerOptions));
    if (!linker)
      continue;

    const packageLocation = await linker.findPackageLocation(dependency, linkerOptions);

    for (const [name, target] of dependency.bin) {
      binaries.set(name, [dependency, npath.fromPortablePath(ppath.resolve(packageLocation, target))]);
    }
  }

  return binaries;
}
github yarnpkg / berry / packages / yarnpkg-pnpify / sources / PortablePnPApi.ts View on Github external
public resolveUnqualified(unqualified: PortablePath, opts?: {extensions?: Array}): PortablePath {
    return npath.toPortablePath(this.pnp.resolveUnqualified(npath.fromPortablePath(unqualified), opts));
  }
github yarnpkg / berry / packages / plugin-pnp / sources / PnpLinker.ts View on Github external
async findPackageLocator(location: PortablePath, opts: LinkOptions) {
    const pnpPath = getPnpPath(opts.project);
    if (!xfs.existsSync(pnpPath))
      throw new UsageError(`The project in ${opts.project.cwd}/package.json doesn't seem to have been installed - running an install there might help`);

    const physicalPath = npath.fromPortablePath(pnpPath);
    const pnpFile = miscUtils.dynamicRequire(physicalPath);
    delete require.cache[physicalPath];

    const locator = pnpFile.findPackageLocator(npath.fromPortablePath(location));
    if (!locator)
      return null;

    return structUtils.makeLocator(structUtils.parseIdent(locator.name), locator.reference);
  }
github yarnpkg / berry / packages / yarnpkg-cli / sources / main.ts View on Github external
function runBinary(path: PortablePath) {
  const physicalPath = npath.fromPortablePath(path);

  if (physicalPath) {
    execFileSync(process.execPath, [physicalPath, ...process.argv.slice(2)], {
      stdio: `inherit`,
      env: {
        ...process.env,
        YARN_IGNORE_PATH: `1`,
      },
    });
  } else {
    execFileSync(physicalPath, process.argv.slice(2), {
      stdio: `inherit`,
      env: {
        ...process.env,
        YARN_IGNORE_PATH: `1`,
      },
github yarnpkg / berry / packages / plugin-node-modules / sources / NodeModulesLinker.ts View on Github external
async findPackageLocator(location: PortablePath, opts: LinkOptions) {
    const pnpPath = getPnpPath(opts.project);
    if (!xfs.existsSync(pnpPath))
      throw new UsageError(`The project in ${opts.project.cwd}/package.json doesn't seem to have been installed - running an install there might help`);

    const physicalPath = npath.fromPortablePath(pnpPath);
    const pnpFile = miscUtils.dynamicRequire(physicalPath);
    delete require.cache[physicalPath];

    const locator = pnpFile.findPackageLocator(npath.fromPortablePath(location));
    if (!locator)
      return null;

    return structUtils.makeLocator(structUtils.parseIdent(locator.name), locator.reference);
  }
github yarnpkg / berry / packages / plugin-version / sources / commands / version / check.tsx View on Github external
async function fetchPreviousNonce(workspace: Workspace, {root, base}: {root: PortablePath, base: string}) {
  const {code, stdout} = await execUtils.execvp(`git`, [`show`, `${base}:${npath.fromPortablePath(ppath.relative(root, ppath.join(workspace.cwd, `package.json` as Filename)))}`], {cwd: workspace.cwd});

  if (code === 0) {
    return getNonce(Manifest.fromText(stdout));
  } else {
    return null;
  }
}
github yarnpkg / berry / packages / yarnpkg-pnp / sources / loader / makeApi.ts View on Github external
resolveRequest: maybeLog(`resolveRequest`, (request: NativePath, issuer: NativePath | null, opts?: ResolveRequestOptions) => {
      const portableIssuer = issuer !== null ? npath.toPortablePath(issuer) : null;

      const resolution = resolveRequest(npath.toPortablePath(request), portableIssuer, opts);
      if (resolution === null)
        return null;

      return npath.fromPortablePath(resolution);
    }),
github yarnpkg / berry / packages / yarnpkg-pnpify / sources / PortablePnPApi.ts View on Github external
public findPackageLocator(location: PortablePath): PackageLocator | null {
    return this.pnp.findPackageLocator(npath.fromPortablePath(location));
  }