Skip to content

Commit

Permalink
Prevent duplicate libraries in list
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <sebjulliand@gmail.com>
  • Loading branch information
sebjulliand committed Dec 7, 2024
1 parent d674af2 commit 4e568b0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,13 @@ export default class IBMiContent {
}

async getLibraries(filters: { library: string; filterType?: FilterType }) {
const libraries = [];
for(const library of filters.library.split(",")){
libraries.push(...await this.getObjectList({ library: "QSYS", object: library.trim(), types: ["*LIB"], filterType: filters.filterType }));
const libraries: IBMiObject[] = [];
for (const library of filters.library.split(",")) {
(await this.getObjectList({ library: "QSYS", object: library.trim(), types: ["*LIB"], filterType: filters.filterType }))
.filter(lib => !libraries.find(l => l.name === lib.name))
.forEach(lib => libraries.push(lib));
}
return libraries;
return libraries;
}

/**
Expand Down Expand Up @@ -946,7 +948,7 @@ export default class IBMiContent {
}

async getAttributes(path: string | (QsysPath & { member?: string }), ...operands: AttrOperands[]) {
const localPath = typeof path === `string` ? path : {...path};
const localPath = typeof path === `string` ? path : { ...path };
const assumeMember = typeof localPath === `object`;
let target: string;

Expand All @@ -965,11 +967,11 @@ export default class IBMiContent {

if (assumeMember) {
target = IBMi.escapeForShell(target);
result = await this.ibmi.sendQsh({ command: `${this.ibmi.remoteFeatures.attr} -p ${target} ${operands.join(" ")}`});
result = await this.ibmi.sendQsh({ command: `${this.ibmi.remoteFeatures.attr} -p ${target} ${operands.join(" ")}` });
} else {
target = Tools.escapePath(target, true);
// Take {DOES_THIS_WORK: `YESITDOES`} away, and all of a sudden names with # aren't found.
result = await this.ibmi.sendCommand({ command: `${this.ibmi.remoteFeatures.attr} -p "${target}" ${operands.join(" ")}`, env: {DOES_THIS_WORK: `YESITDOES`}});
result = await this.ibmi.sendCommand({ command: `${this.ibmi.remoteFeatures.attr} -p "${target}" ${operands.join(" ")}`, env: { DOES_THIS_WORK: `YESITDOES` } });
}

if (result.code === 0) {
Expand Down Expand Up @@ -1054,7 +1056,7 @@ export default class IBMiContent {
}
}

function safeIsoValue(date: Date|undefined) {
function safeIsoValue(date: Date | undefined) {
try {
return date ? date.toISOString().slice(0, 19).replace(`T`, ` `) : ``;
} catch (e) {
Expand Down

0 comments on commit 4e568b0

Please sign in to comment.