How to use the @ionic/utils-fs.fileToString function in @ionic/utils-fs

To help you get started, we’ve selected a few @ionic/utils-fs 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 ionic-team / ionic-cli / packages / ionic / src / commands / ssh / use.ts View on Github external
`${strong(prettyPath(keyPath))} does not appear to exist. Please specify a valid SSH private key.\n` +
          `If you are having issues, try using ${input('ionic ssh setup')}.`
        );
      } else if (e === ERROR_SSH_INVALID_PRIVKEY) {
        throw new FatalException(
          `${strong(prettyPath(keyPath))} does not appear to be a valid SSH private key. (Missing '-----BEGIN RSA PRIVATE KEY-----' header.)\n` +
          `If you are having issues, try using ${input('ionic ssh setup')}.`
        );
      } else {
        throw e;
      }
    }

    const { SSHConfig } = await import('../../lib/ssh-config');
    const sshConfigPath = getConfigPath();
    const text1 = await fileToString(sshConfigPath);
    const conf = SSHConfig.parse(text1);
    ensureHostAndKeyPath(conf, { host: this.env.config.getGitHost(), port: this.env.config.getGitPort() }, keyPath);
    const text2 = SSHConfig.stringify(conf);

    if (text1 === text2) {
      this.env.log.msg(`${strong(prettyPath(keyPath))} is already your active SSH key.`);
      return;
    } else {
      const { diffPatch } = await import('../../lib/diff');
      const diff = await diffPatch(sshConfigPath, text1, text2);

      this.env.log.rawmsg(diff);

      const confirm = await this.env.prompt({
        type: 'confirm',
        name: 'confirm',
github ionic-team / ionic-cli / packages / ionic / src / lib / ssh-config.ts View on Github external
export async function loadFromPath(p: string): Promise {
  const s = await fileToString(p);

  return SSHConfig.parse(s);
}