Skip to content
This repository was archived by the owner on Aug 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #505 from tycrek/update-node
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Moore authored Oct 18, 2023
2 parents 503634a + 5a3077a commit a575ddb
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 187 deletions.
4 changes: 2 additions & 2 deletions _build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const { EOL } = require('os');
const path = require('path');
const fs = require('fs-extra');
const moment = require('moment');
const { DateTime } = require('luxon');
const YAML = require('yaml');

const BUILD_SECTION = {
header: () => readFile('md/_header.md').replace('{{DATE}}', moment().format('MMMM Do YYYY').replace(/ /g, '%20')),
header: () => readFile('md/_header.md').replace('{{DATE}}', DateTime.now().toFormat('MMMM dd, yyyy').replace(/ /g, '%20')),
index: () => readFile('md/_index.md'),
contributing: () => readFile('md/_contributing.md'),
browserExtensions: () => generateBrowserExtensions(),
Expand Down
18 changes: 6 additions & 12 deletions _wiki.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const fs = require('fs-extra'); // Reading README.md
const path = require('path'); // Get the correct path for README.md
const fetch = require('node-fetch'); // Make calls to Reddit from Node.js
const qs = require('qs'); // Properly build a query for node-fetch POST
const moment = require('moment'); // Time-related functions

//#region constants
const fs = require('fs-extra');
const path = require('path');
const fetch = require('node-fetch');
const qs = require('qs');
const { DateTime } = require('luxon');

// REDDIT_: For authentication with Reddit API. Oauth MUST be used. ID and Secret come from a "script" app type.
const REDDIT_USER = process.env.REDDIT_USER || 'username';
Expand All @@ -29,15 +27,12 @@ const ENDPOINTS = {

// Helps POST data be submitted properly
const CONTENT_TYPE = 'application/x-www-form-urlencoded';
//#endregion

// Update the wiki
Promise.all([getLastRevision(), getToken()])
.then(([lastId, token]) => putWiki(lastId, token))
.catch((err) => (console.error(err), process.exit(1)));

//#region functions

/**
* Get the last revision ID on the Wiki. Required otherwise editing the wiki fails
*/
Expand Down Expand Up @@ -96,12 +91,11 @@ function putWiki(lastId, token) {
*/
function fixContent(content) {
// Fix updated timestamp
content = content.replace(/\!\[Updated\](.*?)square\)/g, `#### Updated: ${moment().format('MMMM Do YYYY')}`);
content = content.replace(/\!\[Updated\](.*?)square\)/g, `#### Updated: ${DateTime.now().toFormat('MMMM dd, yyyy')}`);

// Fix published timestamps
content = content.replace(/\!\[Published\]\(https\:\/\/img\.shields\.io\/badge\//g, '**');
content = content.replace(/-informational\?style=flat-square\)/g, '**');

return content;
} // * If this is highlighted weirdly, it's because of the 'updated timestamp' regex, don't worry about it
//#endregion
Loading

0 comments on commit a575ddb

Please sign in to comment.