Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

broccoli-persistent-filter

Package Overview
Dependencies
Maintainers
3
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-persistent-filter - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

52

index.js

@@ -15,3 +15,2 @@ 'use strict';

var debugGenerator = require('debug');
var keyForFile = require('./lib/key-for-file');
var md5Hex = require('md5-hex');

@@ -71,3 +70,4 @@ var Processor = require('./lib/processor');

var destDir = this.outputPath;
var paths = walkSync(srcDir);
var entries = walkSync.entries(srcDir);
var paths = entries.map(byRelativePath);

@@ -84,9 +84,11 @@ this._cache.deleteExcept(paths).forEach(function(key) {

return mapSeries(paths, function rebuildEntry(relativePath) {
return mapSeries(paths, function rebuildEntry(relativePath, i) {
var destPath = destDir + '/' + relativePath;
if (relativePath.slice(-1) === '/') {
var entry = entries[i];
if (entry.isDirectory()) {
mkdirp.sync(destPath);
} else {
if (self.canProcessFile(relativePath)) {
return self.processAndCacheFile(srcDir, destDir, relativePath);
return self.processAndCacheFile(srcDir, destDir, entry);
} else {

@@ -157,4 +159,5 @@ var srcPath = srcDir + '/' + relativePath;

Filter.prototype.processAndCacheFile =
function processAndCacheFile(srcDir, destDir, relativePath) {
function processAndCacheFile(srcDir, destDir, entry) {
var self = this;
var relativePath = entry.relativePath;
var cacheEntry = this._cache.get(relativePath);

@@ -164,3 +167,3 @@ var outputRelativeFile = self.getDestFilePath(relativePath);

if (cacheEntry) {
var hashResult = hash(srcDir, cacheEntry.inputFile);
var hashResult = hash(srcDir, cacheEntry.inputFile, entry);

@@ -195,4 +198,4 @@ if (cacheEntry.hash.hash === hashResult.hash) {

function copyToCache() {
var entry = {
hash: hash(srcDir, relativePath),
var cacheEntry = {
hash: hash(srcDir, relativePath, entry),
inputFile: relativePath,

@@ -203,11 +206,11 @@ outputFile: destDir + '/' + outputRelativeFile,

if (fs.existsSync(entry.cacheFile)) {
fs.unlinkSync(entry.cacheFile);
if (fs.existsSync(cacheEntry.cacheFile)) {
fs.unlinkSync(cacheEntry.cacheFile);
} else {
mkdirp.sync(path.dirname(entry.cacheFile));
mkdirp.sync(path.dirname(cacheEntry.cacheFile));
}
copyDereferenceSync(entry.outputFile, entry.cacheFile);
copyDereferenceSync(cacheEntry.outputFile, cacheEntry.cacheFile);
return self._cache.set(relativePath, entry);
return self._cache.set(relativePath, cacheEntry);
}

@@ -256,13 +259,16 @@ };

function hash(src, filePath) {
var path = src + '/' + filePath;
var key = keyForFile(path);
function hash(src, relativePath, entry) {
var path = src + '/' + relativePath;
if (entry.isDirectory()) {
throw new Error('cannot diff directory');
}
return {
key: key,
key: entry,
hash: helpers.hashStrings([
path,
key.size,
key.mode,
key.mtime
entry.size,
entry.mode,
entry.mtime
])

@@ -277,1 +283,5 @@ };

}
function byRelativePath (entry) {
return entry.relativePath;
}
{
"name": "broccoli-persistent-filter",
"version": "1.0.9",
"version": "1.1.0",
"description": "broccoli filter but with a persistent cache",

@@ -42,3 +42,3 @@ "author": "Stefan Penner <stefan.penner@gmail.com>",

"symlink-or-copy": "^1.0.1",
"walk-sync": "^0.1.3"
"walk-sync": "^0.2.2"
},

@@ -45,0 +45,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc