Socket
Socket
Sign inDemoInstall

broccoli-filter

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

broccoli-filter - npm Package Compare versions

Comparing version 0.1.14 to 0.2.0

6

CHANGELOG.md
# master
# 0.2.0
* Derive from new broccoli-plugin base class. Notably, this means that
subclasses always must call `Filter.call(this, inputTree)` in their
constructors, instead of settings `this.inputTree = inputTree`.
# 0.1.14

@@ -4,0 +10,0 @@

50

index.js

@@ -5,4 +5,3 @@ var fs = require('fs')

var Promise = require('rsvp').Promise
var quickTemp = require('quick-temp')
var Writer = require('broccoli-writer')
var Plugin = require('broccoli-plugin')
var helpers = require('broccoli-kitchen-sink-helpers')

@@ -15,9 +14,9 @@ var walkSync = require('walk-sync')

module.exports = Filter
Filter.prototype = Object.create(Writer.prototype)
Filter.prototype = Object.create(Plugin.prototype)
Filter.prototype.constructor = Filter
function Filter (inputTree, options) {
if (!inputTree) {
throw new Error('broccoli-filter must be passed an inputTree, instead it received `undefined`');
function Filter (inputNode, options) {
if (!inputNode) {
throw new Error('broccoli-filter must be passed an inputNode, instead it received `undefined`');
}
this.inputTree = inputTree
Plugin.call(this, [inputNode])
options = options || {}

@@ -30,31 +29,22 @@ if (options.extensions != null) this.extensions = options.extensions

Filter.prototype.getCacheDir = function () {
return quickTemp.makeOrReuse(this, 'tmpCacheDir')
}
Filter.prototype.write = function (readTree, destDir) {
Filter.prototype.build = function (readTree, destDir) {
var self = this
var srcDir = this.inputPaths[0]
var destDir = this.outputPath
return readTree(this.inputTree).then(function (srcDir) {
var paths = walkSync(srcDir)
var paths = walkSync(srcDir)
return mapSeries(paths, function (relativePath) {
if (relativePath.slice(-1) === '/') {
mkdirp.sync(destDir + '/' + relativePath)
return mapSeries(paths, function (relativePath) {
if (relativePath.slice(-1) === '/') {
mkdirp.sync(destDir + '/' + relativePath)
} else {
if (self.canProcessFile(relativePath)) {
return self.processAndCacheFile(srcDir, destDir, relativePath)
} else {
if (self.canProcessFile(relativePath)) {
return self.processAndCacheFile(srcDir, destDir, relativePath)
} else {
symlinkOrCopySync(srcDir + '/' + relativePath, destDir + '/' + relativePath)
}
symlinkOrCopySync(srcDir + '/' + relativePath, destDir + '/' + relativePath)
}
})
}
})
}
Filter.prototype.cleanup = function () {
quickTemp.remove(this, 'tmpCacheDir')
Writer.prototype.cleanup.call(this)
}
Filter.prototype.canProcessFile = function (relativePath) {

@@ -111,3 +101,3 @@ return this.getDestFilePath(relativePath) != null

mkdirp.sync(path.dirname(dest))
symlinkOrCopySync(self.getCacheDir() + '/' + cacheEntry.cacheFiles[i], dest)
symlinkOrCopySync(self.cachePath + '/' + cacheEntry.cacheFiles[i], dest)
}

@@ -128,3 +118,3 @@ }

destDir + '/' + cacheEntry.outputFiles[i],
self.getCacheDir() + '/' + cacheFile)
self.cachePath + '/' + cacheFile)
}

@@ -131,0 +121,0 @@ cacheEntry.hash = hash(cacheEntry.inputFiles)

{
"name": "broccoli-filter",
"description": "Helper base class for Broccoli plugins that map input files into output files one-to-one",
"version": "0.1.14",
"version": "0.2.0",
"author": "Jo Liss <joliss42@gmail.com>",

@@ -19,6 +19,5 @@ "main": "index.js",

"broccoli-kitchen-sink-helpers": "^0.2.6",
"broccoli-writer": "^0.1.1",
"broccoli-plugin": "^1.0.0",
"mkdirp": "^0.3.5",
"promise-map-series": "^0.2.1",
"quick-temp": "^0.1.2",
"rsvp": "^3.0.16",

@@ -25,0 +24,0 @@ "symlink-or-copy": "^1.0.1",

@@ -8,2 +8,22 @@ # broccoli-filter

### Upgrading from 0.1.x to 0.2.x
You must now call the base class constructor. For example:
```js
// broccoli-filter 0.1.x:
function MyPlugin(inputTree) {
this.inputTree = inputTree;
}
// broccoli-filter 0.2.x:
function MyPlugin(inputNode) {
Filter.call(this, inputNode);
}
```
Note that "node" is simply new terminology for "tree".
### Source Maps
**Can this help with compilers that are almost 1:1, like a minifier that takes

@@ -10,0 +30,0 @@ a `.js` and `.js.map` file and outputs a `.js` and `.js.map` file?**

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