Created
July 7, 2017 16:50
-
-
Save jsonberry/22628365e6301c80bce455650bad65dd to your computer and use it in GitHub Desktop.
Spawn a new task!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/* | |
* Run the Metalsmith build upon hbs and json changes | |
* This enables live reloading of template and data changes | |
*/ | |
const { watch } = require('fs'); | |
const { spawn: run } = require('child_process'); | |
const { resolve, extname } = require('path'); | |
const src = resolve(__dirname, '../src/app'); | |
watch(src, {recursive: true}, (eventType, file) => { | |
let extension = extname(file); | |
if (extension === '.hbs' || extension === '.json') { | |
run('npm', ['run', 'metalsmith'], {stdio: 'inherit'}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment