From 7207f943be828d0ec38d34027bbfee575a350a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= <cpartiot@gmail.com> Date: Fri, 22 Nov 2019 18:43:47 +0100 Subject: [PATCH] bugfix: watch all pug files changes --- compile-pug.js | 9 ++++++--- package.json | 3 +-- src/get_config.pug | 7 ------- 3 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 src/get_config.pug diff --git a/compile-pug.js b/compile-pug.js index 4589b01d..ddb3ba20 100644 --- a/compile-pug.js +++ b/compile-pug.js @@ -8,12 +8,15 @@ const chokidar = require('chokidar') //Set default language const default_lang = 'en' -const pugFile = './src/index.pug' +const pugDir = './src' +const pugFile = `${pugDir}/index.pug` //Set the translation directory const dataDir = './translation' const outDir = './www' +const paramFile = './src/config.json' + //Compile custom function async function compile() { //Retrieve langues proposed @@ -41,7 +44,7 @@ async function compile() { ) } - const options = JSON.parse(await fs.readFile('./src/config.json', 'utf-8')) + const options = JSON.parse(await fs.readFile(paramFile, 'utf-8')) const pugFct = pug.compileFile(pugFile) await fs.mkdir(outDir, { recursive: true }) @@ -64,7 +67,7 @@ async function compile() { compile().then(() => { if (!process.argv.includes('-w') && !process.argv.includes('--watch')) return console.log('watching for changes…') - chokidar.watch([pugFile, dataDir]).on('change', editedFilePath => { + chokidar.watch([`${pugDir}/**/*.pug`, `${dataDir}/**/*.yml`, paramFile]).on('change', editedFilePath => { console.log(`\nchanged: ${editedFilePath}`) compile() }) diff --git a/package.json b/package.json index c0eded18..a838486e 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { - "name": "Coop-starter", + "name": "coop-starter", "version": "1.0.0", "license": "MIT", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "scss": "node-sass -w ./src/styles/index.scss -o ./www/styles/", "pug": "node ./compile-pug.js -w", - "pugprod": "pug ./src/index.pug --out ./www/ --obj prod.json", "copy-js": "cp ./src/scripts/*.js ./www/scripts/", "copy-fonts": "cp -R ./src/fonts ./www", "copy-images": "cp -R ./src/images ./www", diff --git a/src/get_config.pug b/src/get_config.pug deleted file mode 100644 index d2fd8950..00000000 --- a/src/get_config.pug +++ /dev/null @@ -1,7 +0,0 @@ -- var __env = locals[process.env.ENV] - -- - for(k in __env){ - eval(`var ${k} = __env[${JSON.stringify(k)}]`); - } - -- GitLab