Socket
Socket
Sign inDemoInstall

serverless-plugin-browserify

Package Overview
Dependencies
234
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.1.2

31

lib/bundle.js

@@ -8,3 +8,2 @@ 'use strict';

fs = BbPromise.promisifyAll(require('fs-extra')),
_ = require('lodash'),
archiver = require('archiver');

@@ -38,5 +37,7 @@

const handlerPath = path.join(outputDir, functionObject.handler.split('.')[0] + '.js');
functionObject.handler = path.basename(functionObject.handler);
const handlerName = functionObject.handler.split('.')[0];
const handlerPath = path.join(outputDir, handlerName + '.js');
fs.mkdirSync(path.dirname(handlerPath), '0777'); //handler may be in a subdir
fs.mkdirsSync(path.dirname(handlerPath), '0777'); //handler may be in a subdir
fs.writeFile(handlerPath, bundledBuf, (err)=> {

@@ -47,3 +48,3 @@ (err) ? reject(err) : resolve();

})
.then(()=> {
.then(() => {
if (process.env.SLS_DEBUG) {

@@ -53,5 +54,5 @@ this.serverless.cli.log(`Zipping ${outputDir} to ${finalZipFilePath}`);

return zipDir(outputDir, finalZipFilePath);
return zipDir(outputDir, finalZipFilePath, functionBrowserifyConfig.include);
})
.then((sizeBytes)=> {
.then((sizeBytes) => {
const fileSizeInMegabytes = sizeBytes / 1000000.0;

@@ -68,6 +69,6 @@ this.serverless.cli.log(`Created ${functionName}.zip (${Math.round(fileSizeInMegabytes * 100) / 100} MB)...`);

});
},
}
};
function zipDir(dirPath, destZipFilePath) {
function zipDir(dirPath, destZipFilePath, include) {
return new BbPromise((resolve, reject) => {

@@ -77,14 +78,12 @@ let output = fs.createWriteStream(destZipFilePath);

output.on('close', () => {
resolve(archive.pointer());
});
output.on('close', () => resolve(archive.pointer()));
archive.on('error', (err) => reject(err));
archive.pipe(output);
archive
.append('empty so lambda inline editor does not show', {name: 'empty.txt'})
.directory(dirPath, '')
.finalize();
archive.directory(dirPath, '');
if (include && include.length) {
include.forEach((glob) => archive.glob(glob));
}
archive.finalize();
});
}
'use strict';
const xtend = require('xtend'),
_ = require('lodash');
union = require('lodash.union');

@@ -46,7 +46,11 @@ module.exports = {

//Merge together package.exclude and custom.browserify.exclude
if (this.serverless.service.package) {
//Merge together package.exclude and custom.browserify.exclude
if (this.serverless.service.package.exclude && this.serverless.service.package.exclude.length) {
this.globalBrowserifyConfig.exclude = _.union(this.serverless.service.package.exclude, this.globalBrowserifyConfig.exclude);
this.globalBrowserifyConfig.exclude = union(this.serverless.service.package.exclude, this.globalBrowserifyConfig.exclude);
}
//Save service package.include
if (this.serverless.service.package.include && this.serverless.service.package.include.length) {
this.globalBrowserifyConfig.include = this.serverless.service.package.include;
}
}

@@ -85,4 +89,8 @@

if (functionObject.package.exclude && functionObject.package.exclude.length) {
functionBrowserifyConfig.exclude = _.union(functionBrowserifyConfig.exclude, functionObject.package.exclude);
functionBrowserifyConfig.exclude = union(functionBrowserifyConfig.exclude, functionObject.package.exclude);
}
//Merge together service and function includes
if (functionObject.package.include && functionObject.package.include.length) {
functionBrowserifyConfig.include = union(functionBrowserifyConfig.include, functionObject.package.include);
}
}

@@ -95,3 +103,3 @@

return functionBrowserifyConfig;
},
}
};
{
"name": "serverless-plugin-browserify",
"version": "1.0.2",
"version": "1.1.2",
"description": "Serverless v1.0 plugin that uses Browserify to bundle NodeJS Lambda functions.",
"main": "index.js",
"author": "Ryan Pendergast <ryan.pendergast@gmail.com> (http://rynop.com)",
"contributors": [
"Ricardo Nolde <ricardo@nolde.com.br>"
],
"repository": {

@@ -28,3 +31,3 @@ "type": "git",

"fs-extra": "~0.30.0",
"lodash": "^4.16.4",
"lodash.union": "4.6.0",
"xtend": "~4.0.1"

@@ -31,0 +34,0 @@ },

@@ -73,3 +73,3 @@ # Serverless Browserify Plugin

**Note:** `package.include` is ignored when using this plugin. This is a foreign concept in Browserify, every use case I've ever run across can be handled by leveraging [browserify options](https://github.com/substack/node-browserify#browserifyfiles--opts).
**Note:** `package.include` can be used with this plugin. All other options can be handled by leveraging [browserify options](https://github.com/substack/node-browserify#browserifyfiles--opts) in your `serverless.yml` custom `browserify` section.

@@ -76,0 +76,0 @@ ## Usage

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc