Skip to content

Commit

Permalink
Move package.json scripts into copyFile.js (#350)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Winner95 and github-actions[bot] committed Oct 13, 2020
1 parent 76b5082 commit a5da5c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
32 changes: 21 additions & 11 deletions copyFile.js
@@ -1,16 +1,24 @@
const fs = require("fs");

const src = process.argv[2];
const dest = process.argv[3];
const hideHeader = process.argv[4];
const filesTopCopy = [
{
src: "../CONTRIBUTORS.md",
dest: "../docs/contributors.md",
hideHeader: true,
},
{
src: "../CONTRIBUTING.md",
dest: "../docs/contributing.md",
hideHeader: true,
},
];

const generatingPageOptions = `---
hide_title: true
---
`;

function writeNewFile() {
function writeNewFile(src, dest) {
const fileContent = fs.readFileSync(src).toString();
const data = new Uint8Array(Buffer.from(generatingPageOptions + fileContent));

Expand All @@ -23,7 +31,7 @@ function writeNewFile() {
});
}

function copyFile() {
function copyFile(src, dest) {
fs.copyFile(src, dest, (err) => {
if (err) {
console.log("Error Found:", err);
Expand All @@ -33,8 +41,10 @@ function copyFile() {
});
}

if (hideHeader) {
writeNewFile();
} else {
copyFile();
}
filesTopCopy.forEach(({ src, dest, hideHeader }) => {
if (hideHeader) {
writeNewFile(src, dest);
} else {
copyFile(src, dest);
}
});
4 changes: 1 addition & 3 deletions website/package.json
@@ -1,8 +1,6 @@
{
"scripts": {
"add-contributors-on-site": "node ../copyFile.js ../CONTRIBUTORS.md ../docs/contributors.md true",
"add-contributing-on-site": "node ../copyFile.js ../CONTRIBUTING.md ../docs/contributing.md true",
"add-pages-on-site": "yarn add-contributors-on-site && yarn add-contributing-on-site",
"add-pages-on-site": "node ../copyFile.js",
"start": "yarn add-pages-on-site && docusaurus start",
"build": "yarn add-pages-on-site && docusaurus build",
"swizzle": "docusaurus swizzle",
Expand Down

0 comments on commit a5da5c0

Please sign in to comment.