mirror of
https://github.com/shoelace-style/shoelace.git
synced 2026-01-12 02:59:13 +00:00
cleaner watching
This commit is contained in:
@@ -195,6 +195,13 @@ module.exports = function (eleventyConfig) {
|
||||
hasBuiltSearchIndex = true;
|
||||
});
|
||||
|
||||
//
|
||||
// Send a signal to stdout that let's the build know we've reached this point
|
||||
//
|
||||
eleventyConfig.on('eleventy.after', () => {
|
||||
console.log('[eleventy.after]');
|
||||
});
|
||||
|
||||
//
|
||||
// Dev server options (see https://www.11ty.dev/docs/dev-server/#options)
|
||||
//
|
||||
|
||||
@@ -29,7 +29,8 @@ let buildResult;
|
||||
// process and an array of strings containing any output are included in the resolved promise.
|
||||
//
|
||||
async function buildTheDocs(watch = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const afterSignal = '[eleventy.after]';
|
||||
const args = ['@11ty/eleventy', '--quiet'];
|
||||
const output = [];
|
||||
|
||||
@@ -45,12 +46,23 @@ async function buildTheDocs(watch = false) {
|
||||
});
|
||||
|
||||
child.stdout.on('data', data => {
|
||||
if (data.includes(afterSignal)) return; // don't log the signal
|
||||
output.push(data.toString());
|
||||
});
|
||||
|
||||
child.on('close', () => {
|
||||
resolve({ child, output });
|
||||
});
|
||||
if (watch) {
|
||||
// The process doesn't terminate in watch mode so, before resolving, we listen for a known signal in stdout that
|
||||
// tells us when the first build completes.
|
||||
child.stdout.on('data', data => {
|
||||
if (data.includes(afterSignal)) {
|
||||
resolve({ child, output });
|
||||
}
|
||||
});
|
||||
} else {
|
||||
child.on('close', () => {
|
||||
resolve({ child, output });
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user