appendPathToMacOsPathd method

bool appendPathToMacOsPathd(
  1. String path
)

Implementation

bool appendPathToMacOsPathd(String path) {
  var success = false;
  if (!isOnPATH(path)) {
    final macOSPathPath = join(rootPath, 'etc', 'path.d');

    try {
      if (!exists(macOSPathPath)) {
        createDir(macOSPathPath, recursive: true);
      }
      if (exists(macOSPathPath)) {
        join(macOSPathPath, 'dcli${const Uuid().v4()}').write(path);
      }
      success = true;
    }
    // ignore: avoid_catches_without_on_clauses
    catch (e) {
      // ignore write permission problems.
      printerr(
        red(
          "Unable to add $path to path as we couldn't write "
          'to $macOSPathPath',
        ),
      );
    }
  }
  return success;
}