Skip to content

Commit

Permalink
Fix nullish coalescing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
obany committed Jul 22, 2020
1 parent e6b024a commit 34beb5f
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ module.exports = {
"error"
],
"@typescript-eslint/prefer-nullish-coalescing": [
"error"
"off"
],
"@typescript-eslint/prefer-optional-chain": [
"error"
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## v0.6.6
## v0.6.7

Refactored to include CLI
Rewritten in TypeScript
Expand Down
12 changes: 5 additions & 7 deletions action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,6 @@ const iota_1 = __webpack_require__(586);
* @returns The config as non partial.
*/
function sanitizeInput(config) {
var _a, _b, _c;
if (!config.githubToken) {
throw new Error("You must provide the GitHub token option");
}
Expand All @@ -2476,15 +2475,15 @@ function sanitizeInput(config) {
if (config.seed.length !== 81) {
throw new Error(`The seed option must be 81 trytes [A-Z9], it is ${config.seed.length}`);
}
config.transactionTag = (_a = config.transactionTag) !== null && _a !== void 0 ? _a : "GITHUB9RELEASE";
config.transactionTag = config.transactionTag || "GITHUB9RELEASE";
if (!/[9A-Z]/.test(config.transactionTag)) {
throw new Error("The transaction tag option must be 27 trytes [A-Z9] or less");
}
if (config.transactionTag.length >= 27) {
throw new Error(`The transaction tag option must be 27 trytes [A-Z9] or less, it is ${config.transactionTag.length}`);
}
config.explorerUrl = (_b = config.explorerUrl) !== null && _b !== void 0 ? _b : "https://utils.iota.org/transaction/:hash";
config.node = (_c = config.node) !== null && _c !== void 0 ? _c : "https://nodes.iota.cafe:443";
config.explorerUrl = config.explorerUrl || "https://utils.iota.org/transaction/:hash";
config.node = config.node || "https://nodes.iota.cafe:443";
let addressIndex;
let depth;
let mwm;
Expand Down Expand Up @@ -2538,7 +2537,6 @@ exports.sanitizeInput = sanitizeInput;
* @returns The hash of the transaction and an explorer url.
*/
function tangleRelease(config, progress) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
progress("Connecting to GitHub");
let release;
Expand Down Expand Up @@ -2567,8 +2565,8 @@ function tangleRelease(config, progress) {
const zipBallHash = yield crypto_1.downloadAndHash(release.data.zipball_url);
progress("Constructing payload");
const payload = {
owner: (_a = config.owner) !== null && _a !== void 0 ? _a : "",
repo: (_b = config.repository) !== null && _b !== void 0 ? _b : "",
owner: config.owner || "",
repo: config.repository || "",
tag_name: release.data.tag_name,
name: release.data.name,
comment: config.comment,
Expand Down
12 changes: 5 additions & 7 deletions dist/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const iota_1 = require("./iota");
* @returns The config as non partial.
*/
function sanitizeInput(config) {
var _a, _b, _c;
if (!config.githubToken) {
throw new Error("You must provide the GitHub token option");
}
Expand All @@ -42,15 +41,15 @@ function sanitizeInput(config) {
if (config.seed.length !== 81) {
throw new Error(`The seed option must be 81 trytes [A-Z9], it is ${config.seed.length}`);
}
config.transactionTag = (_a = config.transactionTag) !== null && _a !== void 0 ? _a : "GITHUB9RELEASE";
config.transactionTag = config.transactionTag || "GITHUB9RELEASE";
if (!/[9A-Z]/.test(config.transactionTag)) {
throw new Error("The transaction tag option must be 27 trytes [A-Z9] or less");
}
if (config.transactionTag.length >= 27) {
throw new Error(`The transaction tag option must be 27 trytes [A-Z9] or less, it is ${config.transactionTag.length}`);
}
config.explorerUrl = (_b = config.explorerUrl) !== null && _b !== void 0 ? _b : "https://utils.iota.org/transaction/:hash";
config.node = (_c = config.node) !== null && _c !== void 0 ? _c : "https://nodes.iota.cafe:443";
config.explorerUrl = config.explorerUrl || "https://utils.iota.org/transaction/:hash";
config.node = config.node || "https://nodes.iota.cafe:443";
let addressIndex;
let depth;
let mwm;
Expand Down Expand Up @@ -104,7 +103,6 @@ exports.sanitizeInput = sanitizeInput;
* @returns The hash of the transaction and an explorer url.
*/
function tangleRelease(config, progress) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
progress("Connecting to GitHub");
let release;
Expand Down Expand Up @@ -133,8 +131,8 @@ function tangleRelease(config, progress) {
const zipBallHash = yield crypto_1.downloadAndHash(release.data.zipball_url);
progress("Constructing payload");
const payload = {
owner: (_a = config.owner) !== null && _a !== void 0 ? _a : "",
repo: (_b = config.repository) !== null && _b !== void 0 ? _b : "",
owner: config.owner || "",
repo: config.repository || "",
tag_name: release.data.tag_name,
name: release.data.name,
comment: config.comment,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/gh-tangle-release",
"version": "0.6.6",
"version": "0.6.7",
"description": "Create a release and adds metadata to the IOTA Tangle",
"main": "dist/index.js",
"module": "es/index.js",
Expand Down
10 changes: 5 additions & 5 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function sanitizeInput(config: IPartialConfig): IConfig {
throw new Error(`The seed option must be 81 trytes [A-Z9], it is ${config.seed.length}`);
}

config.transactionTag = config.transactionTag ?? "GITHUB9RELEASE";
config.transactionTag = config.transactionTag || "GITHUB9RELEASE";

if (!/[9A-Z]/.test(config.transactionTag)) {
throw new Error("The transaction tag option must be 27 trytes [A-Z9] or less");
Expand All @@ -44,8 +44,8 @@ export function sanitizeInput(config: IPartialConfig): IConfig {
config.transactionTag.length}`);
}

config.explorerUrl = config.explorerUrl ?? "https://utils.iota.org/transaction/:hash";
config.node = config.node ?? "https://nodes.iota.cafe:443";
config.explorerUrl = config.explorerUrl || "https://utils.iota.org/transaction/:hash";
config.node = config.node || "https://nodes.iota.cafe:443";

let addressIndex: number;
let depth: number;
Expand Down Expand Up @@ -139,8 +139,8 @@ export async function tangleRelease(config: IConfig, progress: (message: string)

progress("Constructing payload");
const payload: IPayload = {
owner: config.owner ?? "",
repo: config.repository ?? "",
owner: config.owner || "",
repo: config.repository || "",
tag_name: release.data.tag_name,
name: release.data.name,
comment: config.comment,
Expand Down

0 comments on commit 34beb5f

Please sign in to comment.