Skip to content

Commit

Permalink
feat(pkg): add Webpack support to secrets SDK
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Jul 27, 2023
1 parent df3f6fc commit eaabfa8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
11 changes: 11 additions & 0 deletions packages/secrets/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

export * as keyring from "./src/keyring";

Check warning on line 12 in packages/secrets/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/secrets/index.ts#L12

Added line #L12 was not covered by tests
11 changes: 11 additions & 0 deletions packages/secrets/src/keyring/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

/* tslint:disable */
/* eslint-disable */

Expand Down
21 changes: 16 additions & 5 deletions packages/secrets/src/keyring/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
const path = require("path");
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/

const { join } = require("path");

function getTargetName() {
switch (process.platform) {
Expand All @@ -20,17 +31,17 @@ function getTargetName() {
}
}

const binaryPath = require.resolve(`./keyring.${getTargetName()}.node`, {
paths: [__dirname, path.join(__dirname, "..", "..", "prebuilds")],
const requireFn = typeof __webpack_require__ === "function" ? __non_webpack_require__ : require;
const binaryPath = requireFn.resolve(`./keyring.${getTargetName()}.node`, {
paths: [__dirname, join(__dirname, "..", "..", "prebuilds")],
});

const {
deletePassword,
findCredentials,
findPassword,
getPassword,
setPassword,
} = require(binaryPath);
} = requireFn(binaryPath);

module.exports.deletePassword = deletePassword;
module.exports.findCredentials = findCredentials;
Expand Down

0 comments on commit eaabfa8

Please sign in to comment.