How to use the hexo-util.CacheStream function in hexo-util

To help you get started, we’ve selected a few hexo-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hexojs / hexo / lib / plugins / console / generate.js View on Github external
function writeFile(path, force) {
    const dest = join(publicDir, path);
    const cacheId = `public/${path}`;
    const dataStream = wrapDataStream(route.get(path), {bail});
    const cacheStream = new CacheStream();
    const hashStream = new HashStream();

    // Get data => Cache data => Calculate hash
    return pipeStream(dataStream, cacheStream, hashStream).then(() => {
      const cache = Cache.findById(cacheId);
      const hash = hashStream.read().toString('hex');

      // Skip generating if hash is unchanged
      if (!force && cache && cache.hash === hash) {
        return;
      }

      // Save new hash to cache
      return Cache.save({
        _id: cacheId,
        hash