Skip to content

Commit 05443f9

Browse files
committed
update empty options validation check
1 parent f66fe18 commit 05443f9

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "serverless-prune-versions",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "Serverless plugin to delete old versions of deployed functions from AWS",
55
"scripts": {
66
"build": "rimraf dist && tsc -p tsconfig.build.json",

src/mock-data/options.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ export const defaultOptions: Serverless.Options = {
44
number: '5'
55
};
66

7+
export const emptyOptions = {};
8+
79
export const invalidOptions = {
810
number: '0'
911
};

src/plugin.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { PrunePlugin } from './plugin';
22
import { LOG_PREFIX } from './log';
33
import { getServerless, getServerlessWithFunctions } from './mock-data/serverless';
4-
import { defaultOptions, invalidOptions, dryRunOptions, noDeployOptions } from './mock-data/options';
4+
import { defaultOptions, invalidOptions, dryRunOptions, noDeployOptions, emptyOptions } from './mock-data/options';
55
import { invalidConfig, disabledConfig } from './mock-data/config';
66

77
describe('Prune plugin', () => {
@@ -27,6 +27,11 @@ describe('Prune plugin', () => {
2727
// @ts-ignore
2828
expect(() => new PrunePlugin(mockInvalidServerless)).toThrow();
2929
});
30+
31+
it('Instantiates with empty default options', () => {
32+
const mockServerless = getServerless();
33+
new PrunePlugin(mockServerless, emptyOptions);
34+
});
3035
});
3136

3237
describe('Post deploy pruning', () => {

src/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class Settings implements PruneSettings {
2929
}
3030

3131
private cleanRawOptions(rawOptions?: Serverless.Options): PruneSettings {
32-
if (rawOptions) {
32+
if (rawOptions && Object.keys(rawOptions).length > 0) {
3333
const replacementKeys = { n: 'number', d: 'dryRun', i: 'includeLayers' };
3434
const replacedOptions = Object.keys(rawOptions).map(key => {
3535
const newKey = replacementKeys[key] || key;

0 commit comments

Comments
 (0)