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.2.2 to 1.2.3

77

index.js

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

var FSTree = require('fs-tree-diff');
var IS_VERBOSE = !!process.env.DEBUG_VERBOSE

@@ -46,2 +47,4 @@ module.exports = Filter;

this.resetCounters();
/* Destructuring assignment in node 0.12.2 would be really handy for this! */

@@ -65,5 +68,14 @@ if (options) {

Filter.prototype.build = function() {
var start = Date.now();
var srcDir = this.inputPaths[0];
var destDir = this.outputPath;
var entries = walkSync.entries(srcDir);
this._debug('buildng: %s, %o', '' + this, {
inputPath: srcDir,
outputPath: destDir,
entries: entries.length
});
var nextTree = new FSTree.fromEntries(entries);

@@ -74,2 +86,3 @@ var currentTree = this.currentTree;

var patches = currentTree.calculatePatch(nextTree);
this._counters.patches = patches.length;

@@ -83,20 +96,66 @@ return mapSeries(patches, function(patch) {

this._debug('[operation:%s] %s', operation, relativePath);
this._verboseDebug('[operation:%s] %s', operation, relativePath);
switch (operation) {
case 'mkdir': return fs.mkdirSync(outputPath);
case 'rmdir': return fs.rmdirSync(outputPath);
case 'unlink': return fs.unlinkSync(outputPath);
case 'change':
case 'mkdir': {
this._counters.operations.mkdir++;
return fs.mkdirSync(outputPath);
} case 'rmdir': {
this._counters.operations.rmdir++;
return fs.rmdirSync(outputPath);
} case 'unlink': {
this._counters.operations.unlink++;
return fs.unlinkSync(outputPath);
} case 'change': {
this._counters.operations.change++;
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath, true);
case 'create':
} case 'create': {
this._counters.operations.create++;
return this._handleFile(relativePath, srcDir, destDir, entry, outputFilePath, false);
} default: {
this._counters.operations.other++;
}
}
}, this);
}, this).then(function() {
this._debug('build complete: %s, in: %dms', '' + this, Date.now() - start);
this.debugLogCounters()
this.resetCounters()
}.bind(this))
};
Filter.prototype.debugLogCounters = function() {
this._debug(' - %o', this._counters);
};
Filter.prototype._verboseDebug = function() {
if (IS_VERBOSE) {
this._debug.apply(this, arguments);
}
};
Filter.prototype.resetCounters = function() {
this._counters = {
hit: 0,
prime: 0,
patches: 0,
operations: {
mkdir: 0,
rmdir: 0,
unlink: 0,
change: 0,
create: 0,
other: 0
},
linked: 0,
processed: 0,
selfTime: 0
};
};
Filter.prototype._handleFile = function(relativePath, srcDir, destDir, entry, outputPath, isChange) {
if (this.canProcessFile(relativePath)) {
this._counters.processed++;
return this.processAndCacheFile(srcDir, destDir, entry, isChange);
} else {
this._counters.linked++;
if (isChange) {

@@ -223,6 +282,6 @@ fs.unlinkSync(outputPath);

if (isSame) {
this._debug('[change:%s] but was the same, skipping', relativePath, isSame);
this._verboseDebug('[change:%s] but was the same, skipping', relativePath, isSame);
return;
} else {
this._debug('[change:%s] but was NOT the same, writing new file', relativePath);
this._verboseDebug('[change:%s] but was NOT the same, writing new file', relativePath);
}

@@ -229,0 +288,0 @@ }

6

lib/strategies/persistent.js

@@ -32,3 +32,4 @@ 'use strict';

if (entry.isCached) {
ctx._debug('persistent cache hit: %s', relativePath);
ctx._counters.hit++;
ctx._verboseDebug('persistent cache hit: %s', relativePath);

@@ -39,3 +40,4 @@ string = Promise.resolve(entry.value).then(function(value) {

} else {
ctx._debug('persistent cache prime: %s', relativePath);
ctx._counters.prime++;
ctx._verboseDebug('persistent cache prime: %s', relativePath);
string = new Promise(function(resolve) {

@@ -42,0 +44,0 @@ resolve(ctx.processString(contents, relativePath));

{
"name": "broccoli-persistent-filter",
"version": "1.2.2",
"version": "1.2.3",
"description": "broccoli filter but with a persistent cache",

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

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