New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

enb-tech-wrap

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enb-tech-wrap - npm Package Compare versions

Comparing version

to
0.2.0

9

package.json

@@ -5,3 +5,3 @@ {

"name": "enb-tech-wrap",
"version": "0.1.0",
"version": "0.2.0",
"repository": "git://github.com/bem-kit/enb-wrap",

@@ -28,5 +28,8 @@ "homepage": "https://github.com/bem-kit/enb-wrap",

},
"dependencies": {},
"dependencies": {
"enb": ">= 0.12.0 < 2.0.0",
"vow": "^0.4.13",
"vow-fs": "^0.3.6"
},
"devDependencies": {
"enb": ">= 0.12.0 < 2.0.0",
"eslint": "^3.14.1",

@@ -33,0 +36,0 @@ "eslint-config-pedant": "^0.8.0"

@@ -1,2 +0,2 @@

# enb-wrap
# enb-tech-wrap

@@ -8,3 +8,3 @@ ENB plugin to wrap a file into arbitrary content.

```
npm i enb-wrap --save
npm i -S enb-tech-wrap
```

@@ -15,8 +15,8 @@

```js
[require('enb-wrap/techs/wrap'), {
source: '?.js',
[require('enb-tech-wrap/techs/wrap'), {
filesTarget: '?.js', // source
target: '?.wrapped.js',
before: '/* before */',
after: '/* after */',
wrap: function(content, file) {
wrap: function(file, content) {
return [

@@ -32,2 +32,2 @@ '// The code was taken from ' + file,

© 2014 YANDEX LLC. The Source Code is subject to the terms of the [Mozilla Public License 2.0](LICENSE.txt).
© 2017 YANDEX LLC. The Source Code is subject to the terms of the [Mozilla Public License 2.0](LICENSE.txt).

@@ -0,36 +1,55 @@

var EOL = require('os').EOL,
buildFlow = require('enb/lib/build-flow');
Vow = require('vow'),
vowFs = require('vow-fs');
/**
* enb-wrap
* ========
* @class wrapTechFlow
* @augments {BaseTech}
* @classdesc
*
* Wraps a file into arbitrary content.
* Collects js files, wrapps and concats them together.
*
* **Options**
* @param {Object} [options] Options
* @param {String} [options.target=js] Path to target with compiled file.
* @param {String[]} [options.sourceSuffixes=['js']] Files with specified suffixes involved in the build process.
*
* * *String* **source** — Source file.
* * *String* **target** — Target file.
* * *String* **before** — Text to append before source content.
* * *String* **after** — Text to append after source content.
* * *Function* **wrap** — Wrapper function.
*
* **Example**
*
* ```javascript
* nodeConfig.addTech(require('enb-wrap/techs/wrap'));
* ```
* @example
* addTechs([require('enb-tech-wrap/techs/wrap'), {
* filesTarget: '?.spec.files',
* target: '?.spec.js',
* sourceSuffixes: ['spec.js'],
* beforeAll: 'var b = __env__.GREP_BLOCKS;',
* wrap: function (filename, content) {
* var block = path.basename(filename, '.spec.js');
* return 'if(b ? (new RegExp(b)).test(\'' + block + '\'):true){' + content + '}';
* }
* }])
*/
var vfs = require('enb/lib/fs/async-fs');
module.exports = buildFlow.create()
.name('wrap-tech-flow')
.target('target', '?.js')
.defineOption('beforeAll')
.defineOption('afterAll')
.defineOption('before')
.defineOption('after')
.defineOption('wrap')
.useFileList(['js'])
.builder(function (files) {
var before = this.getOption('before') || '',
after = this.getOption('after') || '',
beforeAll = this.getOption('beforeAll') || '',
afterAll = this.getOption('afterAll') || '',
wrap = this.getOption('wrap');
module.exports = require('enb/lib/build-flow').create()
.name('wrap-flow')
.target('target')
.defineRequiredOption('target')
.defineRequiredOption('source')
.defineOption('before', '')
.defineOption('after', '')
.defineOption('wrap')
.useSourceFilename('source')
.justJoinFiles(function (filename, content) {
var wrapped = this.getOption('before') + content + this.getOption('after');
return this.getOption('wrap').call(this, wrapped, filename);
return Vow.all(files.map(function (file) {
return vowFs.read(file.fullname, 'utf8').then(function (content) {
var wrapped = before + content + after;
return wrap ? wrap.call(this, file.name, wrapped) : wrapped;
});
}, this))
.then(function (res) {
return beforeAll + res.join(EOL) + afterAll;
});
})
.createTech();