Skip to content

Commit

Permalink
Change library validation logic
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <mrliamallan@live.co.uk>
  • Loading branch information
worksofliam committed Apr 3, 2024
1 parent e1763db commit 6e95e84
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/api/IBMiContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,21 +484,26 @@ export default class IBMiContent {
return true;
});

const sanitized = Tools.sanitizeLibraryNames(newLibl);

const result = await this.ibmi.sendQsh({
command: [
`liblist -d ` + Tools.sanitizeLibraryNames(this.ibmi.defaultUserLibraries).join(` `),
...newLibl.map(lib => `liblist -a ` + Tools.sanitizeLibraryNames([lib]))
...sanitized.map(lib => `liblist -a ` + lib)
].join(`; `)
});

if (result.stderr) {
const lines = result.stderr.split(`\n`);

lines.forEach(line => {
const badLib = newLibl.find(lib => line.includes(`ibrary ${lib} `) || line.includes(`ibrary ${Tools.sanitizeLibraryNames([lib])} `));
const isNotFound = line.includes(`CPF2110`);
if (isNotFound) {
const libraryReference = sanitized.find(lib => line.includes(lib));

// If there is an error about the library, remove it
if (badLib) badLibs.push(badLib);
// If there is an error about the library, remove it
if (libraryReference) badLibs.push(libraryReference);
}
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/testing/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,11 @@ export const ContentSuite: TestSuite = {
name: `Test validateLibraryList`, test: async () => {
const content = instance.getContent();

const badLibs = await content?.validateLibraryList([`QSYSINC`, `BEEPBOOP`]);
const badLibs = await content?.validateLibraryList([`SCOOBY`, `QSYSINC`, `BEEPBOOP`]);

assert.strictEqual(badLibs?.includes(`BEEPBOOP`), true);
assert.strictEqual(badLibs?.includes(`QSYSINC`), false);
assert.strictEqual(badLibs?.includes(`SCOOBY`), true);
}
},

Expand Down

0 comments on commit 6e95e84

Please sign in to comment.