From a824a0794aa23b9dba6a843e68990eb09e2345e1 Mon Sep 17 00:00:00 2001 From: Joe Reeve Date: Thu, 13 Dec 2018 11:12:43 +0100 Subject: [PATCH] Moved generation files to .operations --- .env.example => .operations/.env.example | 0 gen-html.js => .operations/gen-html.js | 14 ++++++++------ {out => .operations/out}/.gitignore | 0 package.json => .operations/package.json | 2 +- {res => .operations/res}/github.css | 0 {res => .operations/res}/highlight.pack.js | 0 {res => .operations/res}/normalize.css | 0 {res => .operations/res}/skeleton.css | 0 {res => .operations/res}/template.html | 8 ++++---- .travis.yml | 2 ++ README.chinese.md | 6 +++--- README.md | 6 +++--- 12 files changed, 21 insertions(+), 17 deletions(-) rename .env.example => .operations/.env.example (100%) rename gen-html.js => .operations/gen-html.js (93%) rename {out => .operations/out}/.gitignore (100%) rename package.json => .operations/package.json (93%) rename {res => .operations/res}/github.css (100%) rename {res => .operations/res}/highlight.pack.js (100%) rename {res => .operations/res}/normalize.css (100%) rename {res => .operations/res}/skeleton.css (100%) rename {res => .operations/res}/template.html (75%) diff --git a/.env.example b/.operations/.env.example similarity index 100% rename from .env.example rename to .operations/.env.example diff --git a/gen-html.js b/.operations/gen-html.js similarity index 93% rename from gen-html.js rename to .operations/gen-html.js index d2cd81f2..c16c0a81 100644 --- a/gen-html.js +++ b/.operations/gen-html.js @@ -10,7 +10,7 @@ const imageminPngquant = require('imagemin-pngquant'); const converter = new showdown.Converter(); -const templateFilePath = './res/template.html'; +const templateFilePath = './.operations/res/template.html'; const imageminOpts = { plugins: [ @@ -19,6 +19,8 @@ const imageminOpts = { ] }; +console.info(`Working in [${process.cwd()}]`); + const { GITHUB_TOKEN, TRAVIS_BRANCH, TRAVIS, TRAVIS_REPO_SLUG } = process.env; const isCI = !!TRAVIS; @@ -36,7 +38,7 @@ readDirPromise('./') console.info(`Completed Generation in [${(Date.now() - startTime) / 1000}s]`); const outFileName = path.parse(fileName).name + '.html'; - const outFilePath = path.join('out', outFileName); + const outFilePath = path.join('.operations', 'out', outFileName); console.info(`Writing output to [${outFilePath}]`); await writeFilePromise(outFilePath, outputHTML); @@ -69,7 +71,7 @@ async function processMDFile(filePath = '/', templateHTML = null) { nexHTML = $.html(); } - const fileDir = path.parse(filePath).dir.replace(__dirname, '/') || '/'; + const fileDir = path.parse(filePath).dir.replace(process.cwd(), '/') || '/'; console.log(`Processing file [${filePath}]`); const outHtml = await ( @@ -191,7 +193,7 @@ async function inlineResources(html, filePath = '/') { function readFilePromise(filePath, encoding = 'utf8') { return new Promise((resolve, reject) => { - readFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => { + readFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => { if (err) reject(err); else resolve(content); }); @@ -200,7 +202,7 @@ function readFilePromise(filePath, encoding = 'utf8') { function writeFilePromise(filePath, encoding = 'utf8') { return new Promise((resolve, reject) => { - writeFile(path.resolve(__dirname, './' + filePath), encoding, (err, content) => { + writeFile(path.resolve(process.cwd(), './' + filePath), encoding, (err, content) => { if (err) reject(err); else resolve(content); }); @@ -209,7 +211,7 @@ function writeFilePromise(filePath, encoding = 'utf8') { function readDirPromise(dirPath) { return new Promise((resolve, reject) => { - readdir(path.resolve(__dirname, dirPath), (err, files) => { + readdir(path.resolve(process.cwd(), dirPath), (err, files) => { if (err) reject(err); else resolve(files); }); diff --git a/out/.gitignore b/.operations/out/.gitignore similarity index 100% rename from out/.gitignore rename to .operations/out/.gitignore diff --git a/package.json b/.operations/package.json similarity index 93% rename from package.json rename to .operations/package.json index b6f5563c..e7dc934e 100644 --- a/package.json +++ b/.operations/package.json @@ -4,7 +4,7 @@ "description": "[✔]: assets/images/checkbox-small-blue.png", "main": "gen-html.js", "scripts": { - "build": "node gen-html.js", + "build": "cd .. && node .operations/gen-html.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/res/github.css b/.operations/res/github.css similarity index 100% rename from res/github.css rename to .operations/res/github.css diff --git a/res/highlight.pack.js b/.operations/res/highlight.pack.js similarity index 100% rename from res/highlight.pack.js rename to .operations/res/highlight.pack.js diff --git a/res/normalize.css b/.operations/res/normalize.css similarity index 100% rename from res/normalize.css rename to .operations/res/normalize.css diff --git a/res/skeleton.css b/.operations/res/skeleton.css similarity index 100% rename from res/skeleton.css rename to .operations/res/skeleton.css diff --git a/res/template.html b/.operations/res/template.html similarity index 75% rename from res/template.html rename to .operations/res/template.html index 447d3461..735d4f39 100644 --- a/res/template.html +++ b/.operations/res/template.html @@ -32,11 +32,11 @@
- - + + - - + +