assemble-fs
Advanced tools
Comparing version 0.8.0 to 0.9.0
23
index.js
@@ -67,3 +67,3 @@ /*! | ||
return utils.vfs.src(patterns, opts) | ||
.pipe(utils.vfs.dest(dest, opts)) | ||
.pipe(utils.vfs.dest(dest, opts)); | ||
}); | ||
@@ -88,3 +88,3 @@ | ||
.pipe(utils.handle.once(this, 'onLoad')) | ||
.pipe(utils.handle.once(this, 'onStream')) | ||
.pipe(utils.handle.once(this, 'onStream')); | ||
}); | ||
@@ -119,4 +119,4 @@ | ||
this.define('dest', function(dir, options) { | ||
if (!dir) { | ||
this.define('dest', function(dest, options) { | ||
if (!dest) { | ||
throw new TypeError('expected dest to be a string or function.'); | ||
@@ -126,2 +126,3 @@ } | ||
var output = utils.combine([ | ||
utils.prepare(dest, options), | ||
utils.handle.once(this, 'preWrite'), | ||
@@ -142,3 +143,3 @@ utils.vfs.dest.apply(utils.vfs, arguments), | ||
/** | ||
* Push vinyl files into a collection or list. | ||
* Push vinyl files onto a collection or list. | ||
*/ | ||
@@ -149,3 +150,3 @@ | ||
var name = opts.collection; | ||
var collection, view; | ||
var collection; | ||
@@ -156,3 +157,3 @@ if (app.isApp) { | ||
var stream = utils.through.obj(function(file, enc, next) { | ||
return utils.through.obj(function(file, enc, next) { | ||
if (file.isNull()) { | ||
@@ -163,2 +164,7 @@ next(null, file); | ||
if (utils.isBinary(file)) { | ||
next(null, file); | ||
return; | ||
} | ||
// disable default `onLoad` handling inside templates | ||
@@ -180,5 +186,2 @@ file.options = utils.extend({ onLoad: false }, options, file.options); | ||
}); | ||
app.stream = stream; | ||
return stream; | ||
} |
{ | ||
"name": "assemble-fs", | ||
"description": "Assemble plugin to add methods to assemble for working with the file system, like src, dest, copy and symlink.", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"homepage": "https://github.com/assemble/assemble-fs", | ||
@@ -26,2 +26,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"extend-shallow": "^2.0.1", | ||
"file-is-binary": "^0.2.2", | ||
"fs-exists-sync": "^0.1.0", | ||
"is-valid-app": "^0.2.1", | ||
@@ -42,6 +44,7 @@ "lazy-cache": "^2.0.2", | ||
"mocha": "^3.2.0", | ||
"readable-stream": "^2.2.2", | ||
"rimraf": "^2.5.4", | ||
"should": "^11.1.2", | ||
"sinon": "^1.17.6", | ||
"templates": "^1.0.0", | ||
"should": "^11.2.0", | ||
"sinon": "^1.17.7", | ||
"templates": "^1.2.0", | ||
"vinyl": "^2.0.1" | ||
@@ -52,7 +55,28 @@ }, | ||
"assembleplugin", | ||
"boilerplate", | ||
"build", | ||
"cli", | ||
"cli-app", | ||
"command-line", | ||
"create", | ||
"dev", | ||
"development", | ||
"file", | ||
"framework", | ||
"front", | ||
"frontend", | ||
"fs", | ||
"plugin", | ||
"project", | ||
"projects", | ||
"scaffold", | ||
"scaffolder", | ||
"scaffolding", | ||
"system", | ||
"vinyl" | ||
"template", | ||
"templates", | ||
"vinyl", | ||
"webapp", | ||
"yeoman", | ||
"yo" | ||
], | ||
@@ -59,0 +83,0 @@ "verb": { |
@@ -59,5 +59,5 @@ # assemble-fs [![NPM version](https://img.shields.io/npm/v/assemble-fs.svg?style=flat)](https://www.npmjs.com/package/assemble-fs) [![NPM monthly downloads](https://img.shields.io/npm/dm/assemble-fs.svg?style=flat)](https://npmjs.org/package/assemble-fs) [![NPM total downloads](https://img.shields.io/npm/dt/assemble-fs.svg?style=flat)](https://npmjs.org/package/assemble-fs) [![Linux Build Status](https://img.shields.io/travis/assemble/assemble-fs.svg?style=flat&label=Travis)](https://travis-ci.org/assemble/assemble-fs) | ||
| **Commits** | **Contributor**<br/> | | ||
| **Commits** | **Contributor** | | ||
| --- | --- | | ||
| 79 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 83 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 11 | [doowb](https://github.com/doowb) | | ||
@@ -67,8 +67,8 @@ | ||
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme and API documentation with [verb](https://github.com/verbose/verb): | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -g verb verb-generate-readme && verb | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
@@ -78,6 +78,6 @@ | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install && npm test | ||
``` | ||
@@ -90,11 +90,11 @@ | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](LICENSE). | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
MIT | ||
*** | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.1, on December 29, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 02, 2017._ |
40
utils.js
'use strict'; | ||
var path = require('path'); | ||
var utils = require('lazy-cache')(require); | ||
@@ -13,2 +14,4 @@ var fn = require; | ||
require('extend-shallow', 'extend'); | ||
require('fs-exists-sync', 'exists'); | ||
require('file-is-binary', 'isBinary'); | ||
require('is-valid-app'); | ||
@@ -20,2 +23,39 @@ require('stream-combiner', 'combine'); | ||
// until `vinyl-prepare` is published | ||
utils.prepare = function(dest, file, options, cb) { | ||
return utils.through.obj(function(file, enc, next) { | ||
prepare(dest, file, options, next); | ||
}); | ||
}; | ||
function prepare(dest, file, options, cb) { | ||
try { | ||
var opts = utils.extend({cwd: process.cwd()}, options); | ||
var cwd = path.resolve(opts.cwd); | ||
var destDir = typeof dest === 'function' ? dest(file) : dest; | ||
if (typeof destDir !== 'string') { | ||
cb(new TypeError('expected destination directory to be a string')); | ||
return; | ||
} | ||
var baseDir = typeof opts.base === 'function' | ||
? opts.base(file) | ||
: path.resolve(cwd, destDir); | ||
if (!baseDir) { | ||
cb(new TypeError('expected base directory to be a string')); | ||
return; | ||
} | ||
var writePath = path.resolve(baseDir, file.relative); | ||
file.cwd = cwd; | ||
file.base = baseDir; | ||
file.path = writePath; | ||
cb(null, file); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
} | ||
/** | ||
@@ -22,0 +62,0 @@ * Expose `utils` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14297
202
9
14
3
+ Addedfile-is-binary@^0.2.2
+ Addedfs-exists-sync@^0.1.0
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedfile-is-binary@0.2.3(transitive)
+ Addedfs-exists-sync@0.1.0(transitive)
+ Addedisbinaryfile@3.0.3(transitive)
+ Addedisobject@3.0.1(transitive)