From 5ff9146ff50579c8ad71ada82440797350e4c0ee Mon Sep 17 00:00:00 2001 From: imfunny <36105478+imfunniee@users.noreply.github.com> Date: Mon, 20 May 2019 19:46:32 +0530 Subject: [PATCH] fixed #35 so umm looks like when you used update it would clear out config.json file, resaon being i was updating the html with only one argument and it needed 4 lol mb --- build.js | 12 +++++++++++- update.js | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/build.js b/build.js index cbeb65d..e80ba0d 100644 --- a/build.js +++ b/build.js @@ -58,7 +58,7 @@ async function populateCSS() { themeSource = themeSource.toString('utf-8'); let themeTemplate = hbs.compile(themeSource); let styles = themeTemplate({ - 'background': `${process.background || 'https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450'}` + 'background': `${program.background || 'https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450'}` }) /* Add the user-specified styles to the new stylesheet */ await fs.appendFileAsync(stylesheet, styles); @@ -70,6 +70,15 @@ async function populateCSS() { await fs.writeFileAsync(config, JSON.stringify(data, null, ' ')); } +async function populateConfig(sort, order, includeFork) { + let data = await fs.readFileAsync(config); + data = JSON.parse(data); + data[0].sort = sort; + data[0].order = order; + data[0].includeFork = includeFork; + await fs.writeFileAsync(config, JSON.stringify(data, null, ' ')); +} + populateCSS(); if (program.name) { @@ -82,6 +91,7 @@ if (program.name) { if(program.fork){ includeFork = true; } + populateConfig(sort, order, includeFork); updateHTML(('%s', program.name), sort, order, includeFork); } else { console.error("Error: Please provide a GitHub username."); diff --git a/update.js b/update.js index 90b330b..b167de3 100644 --- a/update.js +++ b/update.js @@ -5,9 +5,12 @@ fs.readFile("./dist/config.json", function (err , data) { if (err) throw err; data = JSON.parse(data); var username = data[0].username; - if(!username || username == null){ + var sort = data[0].sort; + var order = data[0].order; + var includeFork = data[0].includeFork; + if(username == null || sort == null || order == null || includeFork == null){ console.log("username not found in config.json, please run build command before using update"); return; } - updateHTML(username); + updateHTML(username, sort, order, includeFork); }); \ No newline at end of file