Skip to content

Commit

Permalink
chore: rely on nullish coalescing for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgrasset committed Nov 20, 2023
1 parent 5f9d11e commit a2b5814
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,44 @@ const trimTwitterHandle = (handle: string) => {
dotenv.config({ path: envPath });

export const TWITTER_HANDLE = trimTwitterHandle(
process.env.TWITTER_HANDLE || "",
process.env.TWITTER_HANDLE ?? "",
);
export const TWITTER_USERNAME = trimTwitterHandle(
process.env.TWITTER_USERNAME || "",
process.env.TWITTER_USERNAME ?? "",
);
export const TWITTER_PASSWORD = (process.env.TWITTER_PASSWORD || "").trim();
export const MASTODON_INSTANCE = (process.env.MASTODON_INSTANCE || "").trim();
export const TWITTER_PASSWORD = (process.env.TWITTER_PASSWORD ?? "").trim();
export const MASTODON_INSTANCE = (process.env.MASTODON_INSTANCE ?? "").trim();
export const MASTODON_ACCESS_TOKEN = (
process.env.MASTODON_ACCESS_TOKEN || ""
process.env.MASTODON_ACCESS_TOKEN ?? ""
).trim();
export const BLUESKY_INSTANCE = (process.env.BLUESKY_INSTANCE || "").trim();
export const BLUESKY_IDENTIFIER = (process.env.BLUESKY_IDENTIFIER || "").trim();
export const BLUESKY_PASSWORD = (process.env.BLUESKY_PASSWORD || "").trim();
export const BLUESKY_INSTANCE = (process.env.BLUESKY_INSTANCE ?? "").trim();
export const BLUESKY_IDENTIFIER = (process.env.BLUESKY_IDENTIFIER ?? "").trim();
export const BLUESKY_PASSWORD = (process.env.BLUESKY_PASSWORD ?? "").trim();
export const INSTANCE_ID = (TWITTER_HANDLE ?? "instance")
.toLowerCase()
.trim()
.replaceAll(" ", "_");
export const STORAGE_DIR = process.env.STORAGE_DIR ?? process.cwd();
export const CACHE_PATH = `${STORAGE_DIR}/cache.${INSTANCE_ID}.json`;
export const COOKIES_PATH = `${STORAGE_DIR}/cookies.${INSTANCE_ID}.json`;
export const SYNC_MASTODON = (process.env.SYNC_MASTODON || "false") === "true";
export const SYNC_BLUESKY = (process.env.SYNC_BLUESKY || "false") === "true";
export const SYNC_MASTODON = (process.env.SYNC_MASTODON ?? "false") === "true";
export const SYNC_BLUESKY = (process.env.SYNC_BLUESKY ?? "false") === "true";
export const SYNC_FREQUENCY_MIN = parseInt(
process.env.SYNC_FREQUENCY_MIN || "30",
process.env.SYNC_FREQUENCY_MIN ?? "30",
);
export const SYNC_PROFILE_DESCRIPTION =
(process.env.SYNC_PROFILE_DESCRIPTION || "false") === "true";
(process.env.SYNC_PROFILE_DESCRIPTION ?? "false") === "true";
export const SYNC_PROFILE_PICTURE =
(process.env.SYNC_PROFILE_PICTURE || "false") === "true";
(process.env.SYNC_PROFILE_PICTURE ?? "false") === "true";
export const SYNC_PROFILE_NAME =
(process.env.SYNC_PROFILE_NAME || "false") === "true";
(process.env.SYNC_PROFILE_NAME ?? "false") === "true";
export const SYNC_PROFILE_HEADER =
(process.env.SYNC_PROFILE_HEADER || "false") === "true";
export const SYNC_DRY_RUN = (process.env.SYNC_DRY_RUN || "false") === "true";
export const DEBUG = (process.env.TOUITOMAMOUT_DEBUG || "false") === "true";
export const DAEMON = (process.env.DAEMON || "false") === "true";
(process.env.SYNC_PROFILE_HEADER ?? "false") === "true";
export const SYNC_DRY_RUN = (process.env.SYNC_DRY_RUN ?? "false") === "true";
export const DEBUG = (process.env.TOUITOMAMOUT_DEBUG ?? "false") === "true";
export const DAEMON = (process.env.DAEMON ?? "false") === "true";
export const VOID = "∅";
export const API_RATE_LIMIT = parseInt(process.env.API_RATE_LIMIT ?? "30");
export const TOUITOMAMOUT_VERSION = buildInfo.version || "0.0.0";
export const TOUITOMAMOUT_VERSION = buildInfo.version ?? "0.0.0";
export const MASTODON_MAX_POST_LENGTH = 500;
export const BLUESKY_MAX_POST_LENGTH = 300;

0 comments on commit a2b5814

Please sign in to comment.