Skip to content

Commit

Permalink
Create AIX mainline support (#13)
Browse files Browse the repository at this point in the history
* Add AIX mainstream support

* remove no-longer-needed AIX variant check

* add ibmi.js to package.json

* Fix style errors
  • Loading branch information
ThePrez authored and silverwind committed Mar 6, 2019
1 parent 2a7d01a commit eb1bce7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 0 additions & 9 deletions aix.js → ibmi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ const execa = require("execa");
const db2util = "/QOpenSys/pkgs/bin/db2util";
const sql = "select NEXT_HOP, LOCAL_BINDING_INTERFACE from QSYS2.NETSTAT_ROUTE_INFO where ROUTE_TYPE='DFTROUTE' and NEXT_HOP!='*DIRECT' and CONNECTION_TYPE=?";

const checkVariant = () => {
const variant = require("os").type();
if (variant !== "OS400") {
throw new Error(`Unsupported AIX variant: ${variant}`);
}
};

const parse = stdout => {
let result;
try {
Expand All @@ -27,12 +20,10 @@ const parse = stdout => {
};

const promise = family => {
checkVariant();
return execa.stdout(db2util, [sql, "-p", family, "-o", "json"]).then(stdout => parse(stdout));
};

const sync = family => {
checkVariant();
const {stdout} = execa.sync(db2util, [sql, "-p", family, "-o", "json"]);
return parse(stdout);
};
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ if ([
"win32",
"aix",
].indexOf(platform) !== -1) {
const families = require(`./${platform}`);
let platformModule = `./${platform}`;
if (platform === "aix") {
platformModule = (require("os").type() === "OS400") ? "./ibmi.js" : "./sunos.js";
}
const families = require(platformModule);
module.exports.v4 = () => families.v4();
module.exports.v6 = () => families.v6();
module.exports.v4.sync = () => families.v4.sync();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"openbsd.js",
"sunos.js",
"win32.js",
"aix.js"
"ibmi.js"
],
"keywords": [
"default gateway",
Expand Down

0 comments on commit eb1bce7

Please sign in to comment.