Skip to content
This repository has been archived by the owner on Mar 27, 2020. It is now read-only.

Commit

Permalink
Disable plugin if running Serverless <1.34.0 (#21)
Browse files Browse the repository at this point in the history
Closes #20
  • Loading branch information
kolanos authored Jun 11, 2019
1 parent 4360989 commit f89e9cf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
A [Serverless](https://serverless.com) plugin to add [IOpipe](https://www.iopipe.com)
observability using [AWS Lambda Layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) without requiring a code change.

## Requirements

* serverless >= 1.34.0

## Features

* Supports Node.js and Python runtimes (more runtimes to come)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-iopipe-layers",
"version": "0.2.6",
"version": "0.2.7",
"description": "Serverless plugin to add IOpipe lambda layers.",
"main": "dist/index.js",
"files": [
Expand Down Expand Up @@ -37,6 +37,7 @@
"dependencies": {
"fs-extra": "^7.0.1",
"lodash": "^4.17.11",
"semver": "^6.1.1",
"serverless": "^1.34.0"
},
"keywords": [
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "fs-extra";
import * as path from "path";

import * as _ from "lodash";
import * as semver from "semver";
import * as Serverless from "serverless";

import * as layerArns from "./layers";
Expand Down Expand Up @@ -40,13 +41,23 @@ export default class IOpipeLayerPlugin {
}

public run() {
const version = this.serverless.getVersion();

if (semver.lt(version, "1.34.0")) {
this.serverless.cli.log(
`Serverless ${version} does not support layers. Please upgrade to >=1.34.0.`
);
return;
}

const funcs = this.functions;

Object.keys(funcs).forEach(funcName => {
const funcDef = funcs[funcName];
this.addLayer(funcName, funcDef);
});
}

public cleanup() {
this.removeNodeHelper();
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,10 @@ semver@^5.0.3, semver@^5.1.0, semver@^5.3.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"

semver@^6.1.1:
version "6.1.1"
resolved "https://registry.yarnpkg.com/semver/-/semver-6.1.1.tgz#53f53da9b30b2103cd4f15eab3a18ecbcb210c9b"

serverless-iopipe-layers@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/serverless-iopipe-layers/-/serverless-iopipe-layers-0.2.1.tgz#dc192f2ef3cba789cb313e42bc26247802698b34"
Expand Down

0 comments on commit f89e9cf

Please sign in to comment.