Open kennydude opened 8 years ago
What is your setup?
I have a working gulp task, setup somewhat like this:
'use strict';
var gulp = require('gulp');
var aglio = require('aglio');
var browserSync = require('browser-sync');
var config = require('../config');
var logger = require('../../lib/logger');
gulp.task('docs', function() {
var options = {
themeVariables: 'slate',
themeTemplate: 'triple',
};
aglio.renderFile(config.input, config.output, options, function(err, html, warnings) {
if (err) {
return logger.error('Error while rendering blueprint:', err);
}
if (warnings) {
logger.warn('Warning while rendering blueprint:', warnings);
}
if (browserSync.active) {
browserSync.reload();
}
});
});
gulp.task('watch', ['browserSync', 'server'], function() {
gulp.watch(config.input, ['docs']);
});
I just run it like so aglio -s -i docs.apib
I am currently experiencing the same issue as @kennydude on ArchLinux with aglio 2.3.0
After digging for a while, I realized that the length of the blueprint document being read was often 0, so I suspected there was a race condition happening while the file was being read.
The documentation of chokidar confirmed my suspicion, explaining things clearly:
By default, the add event will fire when a file first appear on disk, before the entire file has been written. Furthermore, in some cases some change events will be emitted while the file is being written. In some cases, especially when watching for large files there will be a need to wait for the write operation to finish before responding to a file creation or modification.
I will post a pull request shortly.
When using Live-reload aglio will sometimes render an entirely blank version of my blueprint. The only way to fix this is to stop and restart the command and it works correctly.
This is using aglio 2.2 and nodejs 2.5.0