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

gulp-derequire

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-derequire - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

CHANGELOG.md

9

index.js

@@ -12,16 +12,11 @@ /**

gutil = require('gulp-util'),
xtend = require('xtend'),
derequire = require('derequire'),
BufferStreams = require('bufferstreams');
module.exports = function (params) {
module.exports = function (tokenTo, tokenFrom) {
'use strict';
var opts = xtend({
tokenTo: '_dereq_',
tokenFrom: 'require'
}, params);
var transform = function (code) {
return new Buffer(derequire(code, opts.tokenTo, opts.tokenFrom));
return new Buffer(derequire(code, tokenTo, tokenFrom));
};

@@ -28,0 +23,0 @@

{
"name": "gulp-derequire",
"description": "A Gulp plugin to apply derequire to target Buffer/Stream",
"version": "1.1.0",
"version": "2.0.0",
"author": {

@@ -11,2 +11,8 @@ "name": "Takuto Wada",

"bugs": "https://github.com/twada/gulp-derequire/issues",
"contributors": [
{
"name": "Calvin Metcalf",
"url": "https://github.com/calvinmetcalf"
}
],
"dependencies": {

@@ -16,4 +22,3 @@ "bufferstreams": "^0.0.2",

"gulp-util": "^3.0.1",
"through2": "^1.1.1",
"xtend": "^4.0.0"
"through2": "^1.1.1"
},

@@ -25,2 +30,3 @@ "devDependencies": {

"files": [
"CHANGELOG.md",
"README.md",

@@ -27,0 +33,0 @@ "index.js",

@@ -37,20 +37,10 @@ # gulp-derequire

### derequire(options)
### derequire(parameters)
__Note:__ According to the [derequire](https://github.com/calvinmetcalf/derequire) README, the token you're changing from and the token you're changing to need to be the same length.
__Note:__ parameters are passed verbetim to derequrie so see [its readme](https://github.com/calvinmetcalf/derequire) for options
#### options.tokenFrom
Type: `String`
Default value: `'require'`
#### customization example
Target identifier to replace from.
to change both require and define
#### options.tokenTo
Type: `String`
Default value: `'_dereq_'`
Identifier to replace to.
#### customization example
```javascript

@@ -65,6 +55,12 @@ var derequire = require('gulp-derequire');

.pipe(source('yourModule.js'))
.pipe(derequire({
tokenTo: '_dereq_',
tokenFrom: 'require'
}))
.pipe(derequire([
{
from: 'require',
to: '_dereq_'
},
{
from: 'define',
to: '_defi_'
}
]))
.pipe(gulp.dest('./build'));

@@ -71,0 +67,0 @@ });

@@ -72,3 +72,38 @@ /*global describe, it*/

});
it('it should work with options', function (done) {
var stream = derequire( [
{
from: 'require',
to: '_derec_'
},
{
from: 'define',
to: '_defi_'
}
]),
srcFile = new gutil.File({
path: 'test/fixtures/define.require.js',
cwd: 'test/',
base: 'test/fixtures',
contents: fs.readFileSync('test/fixtures/define.require.js')
}),
expectedFile = new gutil.File({
path: 'test/expected/define.require.js',
cwd: 'test/',
base: 'test/expected',
contents: fs.readFileSync('test/expected/define.require.js')
});
stream.on('error', function(err) {
assert(err);
done(err);
});
stream.on('data', function (newFile) {
assert(newFile);
assert(newFile.contents);
assert.equal(String(newFile.contents), String(expectedFile.contents));
done();
});
stream.write(srcFile);
stream.end();
});
});
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