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

baconize

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baconize - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

examples/site/dont-compile/foo.coffee

14

lib/index.js

@@ -7,7 +7,8 @@ 'use strict';

var path = require('path');
var when = require('when');
var fs = require('fs');
var mm = require('micromatch');
var nodefn = require('when/node');
var when = require('when');
var rimraf = nodefn.lift(require('rimraf'));
var mkdirp = nodefn.lift(require('mkdirp'));
var fs = require('fs');
var fsp = nodefn.liftAll(require('fs'));

@@ -17,6 +18,8 @@ var filesCopied = 0;

module.exports = function(inputDir, outputDir, options) {
options = options || {};
var compileAndCopy = function() {
return when.promise(function(resolve, reject) {
var stream = readdirp({ root: inputDir, options: options });
options.root = inputDir;
var stream = readdirp(options);

@@ -68,3 +71,5 @@ stream.pipe(through.obj(function (file, _, next) {

if (!!compileExt) {
var doCompile = !mm(file.path, options.compileBlacklist).length;
if (!!compileExt && doCompile) {
compile();

@@ -75,2 +80,3 @@ } else {

};
var dir = path.join(outputDir, file.path.replace(file.name, ''));

@@ -77,0 +83,0 @@ mkdirp(dir).then(processFile, reject);

{
"name": "baconize",
"version": "0.1.1",
"version": "0.2.0",
"description": "Compile static site for production (with sourcemaps), auto-compiles files like `app.coffee -> app.js`",

@@ -32,2 +32,3 @@ "main": "lib/index.js",

"baby-tolk": "^1.1.0",
"micromatch": "^2.2.0",
"mkdirp": "^0.5.1",

@@ -34,0 +35,0 @@ "readdirp": "^2.0.0",

@@ -19,3 +19,3 @@ Baconize

var target = '/path/to/output/dir';
baconize(source, target).then([successFn],[errorFn]);
baconize(source, target, [options]).then([successFn],[errorFn]);
```

@@ -30,5 +30,32 @@

This library is designed for use alongside [pingy-in-the-middle](https://github.com/davej/piggy-in-the-middle).
Options
-------
- **compileBlacklist**: filter to blacklist files from being compiled. They will still be copied (without compilation) unless they are negated using the `fileFilter` or `directoryFilter Options below`. This option is useful for vendor directories (like 'bower_components') which already include the compiled versions of files. See [Filters](#filters) for more.
- **fileFilter**: filter to include/exclude files to be copied to target. See [Filters](#filters) for more.
- **directoryFilter**: filter to include/exclude directories to be copied to target, rules are applied to sub-directories also. See [Filters](#filters) for more.
- **depth**: depth at which to stop recursing even if more subdirectories are found.
Filters
-------
Filters take an array of glob strings:
* `compileBlacklist: [ 'bower_components/**' ]` includes bower_components directory but copies the raw directory instead of compiling files within the directory.
* `fileFilter: [ '*.json', '*.js' ]` includes all JavaScript and Json files.
* `directoryFilter: [ '!.git', '!node_modules' ]` includes all directories except the '.git' and 'node_modules'.
See [minimatch](https://github.com/isaacs/minimatch) for some examples of glob strings.
Try it out

@@ -35,0 +62,0 @@ ----------

@@ -27,3 +27,7 @@ 'use strict';

it('should compile compilable files and copy all others', function () {
return expect(baconize(getPathIn(), getPathOut()), 'to be fulfilled with', 4);
var options = {
compileBlacklist: ['dont-compile/**'],
directoryFilter: ['!dont-copy']
};
return expect(baconize(getPathIn(), getPathOut(), options), 'to be fulfilled with', 5);
});

@@ -38,3 +42,4 @@

fs.readFile(getPathOut('scripts/main.js')),
fs.readFile(getPathOut('about.html'))
fs.readFile(getPathOut('about.html')),
fs.readFile(getPathOut('dont-compile/foo.coffee'))
]).then(function(results) {

@@ -45,3 +50,4 @@ return expect.promise.all([

expect(results[2].toString(), 'to contain', 'console.log("H'),
expect(results[3].toString(), 'to contain', '<title>Some')
expect(results[3].toString(), 'to contain', '<title>Some'),
expect(results[4].toString(), 'to contain', 'console.log "T')
]);

@@ -80,3 +86,3 @@ });

.then(function() {
return expect.fail('index.jade should not have been copied');
return expect.fail('`index.jade` should not be copied');
}, function(err) {

@@ -87,4 +93,22 @@ return expect(err.code, 'to be', 'ENOENT');

it('should not compile blacklist matches', function() {
return fs.readFile(getPathOut('dont-compile/foo.js'))
.then(function() {
return expect.fail('`dont-compile/foo.js` should not be copied');
}, function(err) {
return expect(err.code, 'to be', 'ENOENT');
});
});
it('should not copy ignore paths', function() {
return fs.stat(getPathOut('dont-copy'))
.then(function() {
return expect.fail('`dont-copy` directory should not be copied');
}, function(err) {
return expect(err.code, 'to be', 'ENOENT');
});
});
});
});

Sorry, the diff of this file is not supported yet

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