
Security News
CISA Kills Off RSS Feeds for KEVs and Cyber Alerts
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
gulp-wrap-file
Advanced tools
A gulp plugin to wrap a file contents.
Firstly, install gulp-wrap-file
as a development dependency:
npm install gulp-wrap-file --save-dev
Then, add it into your gulpfile.js
:
Wrap the commonjs contents with amd:
var wrapper = require("gulp-wrap-file");
gulp.src("./src/**/*.js")
.pipe(wrap({type: 'amd'}))
.pipe(gulp.dest("build"));
Wrap the contents by your file wrapper:
var wrap = require("gulp-wrap-file");
gulp.src("./src/**/*.js")
.pipe(wrap({wrapper: 'define({file});'}))
.pipe(gulp.dest("build"));
Wrap the contents with modName:
var wrap = require("gulp-wrap-file");
gulp.src("./src/**/*.js")
.pipe(wrap({wrapper: 'define("src/{modName}",function((require, exports, module){ {file} }));'}))
.pipe(gulp.dest("build"));
//input.js
function foo() { console.log("hello world"); }
var wrap = require("gulp-wrap-file");
gulp.src("input.js")
.pipe(wrap({wrapper: 'define("demo/{modName}",function((require, exports, module){ {file} }));'}))
.pipe(gulp.dest("build"));
same to the wrapper for function
var wrap = require("gulp-wrap-file");
gulp.src("input.js")
.pipe(wrap({wrapper: function(content, file){
return 'define("demo/'+file.modName+'",function((require, exports, module){ '+content+' }));'
}}))
.pipe(gulp.dest("build"));
define("demo/input",function((require, exports, module){ function foo() { console.log("hello world"); } }));
Type: String
To wrap file with default support wrapper. On now, it only supports amd
.
Type: String
or Function
The file wrapper to wrap your file content. You can get the file content and the pathname of the file.
If wrapper is string, file content names {file}
, short pathname of the file names {modName}
.
If wrapper is function, the arguments of the function are content of the file and the file object.
Type: Number
To truncate the name of the module prefix. For example, if the module name is path/to/foo. The value of truncatePrefixLen is 1, then the result will be to/foo.
Type: Function
To handle the module name to what you want. With the config of nameReplacer, truncatePrefixLen will be disabled.
FAQs
a gulp plugin for wrapping file content
We found that gulp-wrap-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.