How to use normalize-path - 10 common examples

To help you get started, we’ve selected a few normalize-path 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 LeagueDevelopers / lol-skins-viewer / app / utils / validatePath.js View on Github external
}

  const absolutePath = resolvePath(nextPath);
  if (!absolutePath || !await exists(absolutePath)) {
    return {
      value: nextPath,
      isValidPath: false,
      isValid: false
    };
  }
  const dirIsValid = await isDirectory(absolutePath);
  // TODO: OSX Compatibility
  const files = await readdir(absolutePath);
  const isValid = files.some(f => (f && f.toLowerCase()) === 'leagueclient.exe');
  return {
    value: isValid ? normalize(nextPath) : nextPath,
    isValidPath: dirIsValid,
    isValid
  };
}
github Mayank1791989 / gql / src / gql-config / normalizePkg.js View on Github external
export function normalizePkgName(prefix: string, pkg: string) {
  const normalizedPkg = normalizePath(pkg);

  if (path.isAbsolute(pkg) || isRelative(pkg)) {
    return normalizedPkg;
  }

  const parsed = parsePkg(normalizedPkg);

  if (parsed.name.startsWith(prefix)) {
    return normalizedPkg;
  }

  // need to add prefix
  return parsed.scope
    ? `@${parsed.scope}/${prefix}-${parsed.name}`
    : `${prefix}-${parsed.name}`;
}
github GetPublii / Publii / app / src / components / basic-elements / SmallImageUpload.vue View on Github external
ipcRenderer.once('app-image-uploaded', (event, data) => {
                this.isEmpty = false;
                this.fileName = 'media/website/' + normalizePath(data.baseImage.newPath).split('/').pop();
                this.isUploading = false;
            });
        },
github getgridea / gridea / src / server / plugins / deploys / sftp.ts View on Github external
if (setting.privateKey) {
      try {
        connectConfig.privateKey = fse.readFileSync(setting.privateKey)
      } catch (e) {
        console.error('SFTP Test Remote Error: ', e.message)
        result.success = false
        result.message = e.message
        return result
      }
    } else {
      connectConfig.password = setting.password
    }

    const testFilename = 'gridea.txt'
    const localTestFilePath = normalizePath(path.join(this.appDir, testFilename))
    const remoteTestFilePath = normalizePath(path.join(setting.remotePath, testFilename))

    try {
      await client.connect(connectConfig)
      await client.list('/')

      try {
        fse.writeFileSync(localTestFilePath, 'This is gridea test file. you can delete it.')

        await client.put(localTestFilePath, remoteTestFilePath)
        await client.delete(remoteTestFilePath)
      } catch (e) {
        console.error('SFTP Test Remote Error: ', e.message)
        result.success = false
        result.message = e.message
      } finally {
        if (fse.existsSync(localTestFilePath)) {
github getgridea / gridea / src / server / plugins / deploys / sftp.ts View on Github external
if (setting.privateKey) {
      try {
        connectConfig.privateKey = fse.readFileSync(setting.privateKey)
      } catch (e) {
        console.error('SFTP Test Remote Error: ', e.message)
        result.success = false
        result.message = e.message
        return result
      }
    } else {
      connectConfig.password = setting.password
    }

    const testFilename = 'gridea.txt'
    const localTestFilePath = normalizePath(path.join(this.appDir, testFilename))
    const remoteTestFilePath = normalizePath(path.join(setting.remotePath, testFilename))

    try {
      await client.connect(connectConfig)
      await client.list('/')

      try {
        fse.writeFileSync(localTestFilePath, 'This is gridea test file. you can delete it.')

        await client.put(localTestFilePath, remoteTestFilePath)
        await client.delete(remoteTestFilePath)
      } catch (e) {
        console.error('SFTP Test Remote Error: ', e.message)
        result.success = false
        result.message = e.message
      } finally {
github elastic / kibana / src / dev / i18n / utils.js View on Github external
export function normalizePath(inputPath) {
  return normalize(path.relative('.', inputPath));
}
github teambit / bit / src / utils / path.js View on Github external
export function pathNormalizeToLinux(pathToNormalize?: PathOsBased): PathLinux {
  return pathToNormalize ? normalize(pathToNormalize) : pathToNormalize;
}
export function pathRelativeLinux(from: PathOsBased, to: PathOsBased): PathLinux {
github teambit / bit / src / utils / path.js View on Github external
export function pathResolveToLinux(arr: PathOsBased[]): PathLinux {
  return normalize(path.resolve(arr.join(',')));
}
github zinserjan / mocha-webpack / src / webpack / loader / entryLoader.js View on Github external
addFile(file: string): void {
    const normalizedFile = normalizePath(file);
    this.files.push(normalizedFile);
  }
github GetPublii / Publii / app / src / components / basic-elements / ImageUpload.vue View on Github external
drop (e) {
            this.stopEvents(e);
            let sourcePath = normalizePath(e.dataTransfer.files[0].path);
            this.uploadImage(sourcePath);
        },
        remove (e) {

normalize-path

Normalize slashes in a file path to be posix/unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes, unless disabled.

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis

Popular normalize-path functions