packagex_utils_extension_toLinuxProgram method

String packagex_utils_extension_toLinuxProgram()

Convert any text symbol example: "slebew_corp" converted to "slebew-corp"

Implementation

String packagex_utils_extension_toLinuxProgram() {
  String text = this;
  List<RegExpReplace> regExpReplaces = [
    RegExpReplace(
      from: RegExp("([._]+)"),
      replace: (match) {
        return "-";
      },
    ),
  ];
  for (var i = 0; i < regExpReplaces.length; i++) {
    RegExpReplace regExpReplace = regExpReplaces[i];

    text = text.replaceAllMapped(regExpReplace.from, regExpReplace.replace);
  }

  return text;
}