How to use the hexo-util.HashStream 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
      }).then(() => // Write cache data to public folder
github hexojs / hexo-cli / test / scripts / init.js View on Github external
function compareFile(a, b) {
    const streamA = new util.HashStream();
    const streamB = new util.HashStream();

    return Promise.all([
      pipeStream(fs.createReadStream(a), streamA),
      pipeStream(fs.createReadStream(b), streamB)
    ]).then(() => streamA.read().equals(streamB.read()));
  }
github hexojs / hexo-cli / test / scripts / init.js View on Github external
function compareFile(a, b) {
    const streamA = new util.HashStream();
    const streamB = new util.HashStream();

    return Promise.all([
      pipeStream(fs.createReadStream(a), streamA),
      pipeStream(fs.createReadStream(b), streamB)
    ]).then(() => streamA.read().equals(streamB.read()));
  }
github hexojs / hexo / lib / box / index.js View on Github external
return new Promise((resolve, reject) => {
    const src = createReadStream(path);
    const hasher = new HashStream();

    src.pipe(hasher)
      .on('finish', () => {
        resolve(hasher.read().toString('hex'));
      })
      .on('error', reject);
  });
}