wireguard-tools-extended
Version:
The best way to interact with WireGuard from Node
39 lines (38 loc) • 1.29 kB
JavaScript
;
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lsToArray = void 0;
function lsToArray(stdout) {
var e_1, _a;
var data = stdout.split("\n");
var files = [];
try {
for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
var file = data_1_1.value;
// Remove empty lines
if (/^\s*$/.test(file))
continue;
if (file.includes(".conf"))
files.push(file);
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (data_1_1 && !data_1_1.done && (_a = data_1.return)) _a.call(data_1);
}
finally { if (e_1) throw e_1.error; }
}
return files;
}
exports.lsToArray = lsToArray;