nativescript-doctor
Version:
Library that helps identifying if the environment can be used for development of {N} apps.
45 lines (44 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class Helpers {
constructor(hostInfo) {
this.hostInfo = hostInfo;
}
getPropertyName(method) {
if (method) {
const match = method.toString().match(/(?:return\s+?.*\.(.+);)|(?:=>\s*?.*\.(.+)\b)/);
if (match) {
return (match[1] || match[2]).trim();
}
}
return null;
}
quoteString(value) {
if (!value) {
return value;
}
return this.hostInfo.isWindows ? this.cmdQuote(value) : this.bashQuote(value);
}
appendZeroesToVersion(version, requiredVersionLength) {
if (version) {
const zeroesToAppend = requiredVersionLength - version.split(".").length;
for (let index = 0; index < zeroesToAppend; index++) {
version += ".0";
}
}
return version;
}
bashQuote(s) {
if (s[0] === "'" && s[s.length - 1] === "'") {
return s;
}
return "'" + s.replace(/'/g, '\'"\'"\'') + "'";
}
cmdQuote(s) {
if (s[0] === '"' && s[s.length - 1] === '"') {
return s;
}
return '"' + s.replace(/"/g, '\\"') + '"';
}
}
exports.Helpers = Helpers;