Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit 835d196

Browse files
committed
Fexed issues under node 10
1 parent a8f6cdd commit 835d196

File tree

8 files changed

+35
-9
lines changed

8 files changed

+35
-9
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.git
2+
node_modules
3+
/*.zip
4+
.history

__tests__/lib/brotli/compress.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ describe('brotli compress', () => {
55
jest.resetModules();
66
});
77

8-
test('returns a promise', () => {
9-
expect(typeof compress('').then).toBe('function');
8+
test('returns a promise', async () => {
9+
const result = compress('');
10+
expect(typeof result.then).toBe('function');
11+
await result;
1012
});
1113

1214
test('resolves a promise with Buffer object', async () => {
@@ -17,7 +19,7 @@ describe('brotli compress', () => {
1719

1820
test('result output is smaller then input', async () => {
1921
const input = 'test input to compress';
20-
const output = await compress(input).toString();
22+
const output = (await compress(input)).toString();
2123

2224
expect(output.length).toBeLessThan(input.length);
2325
});

__tests__/lib/gzip/compress.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ describe('gzip compress', () => {
33
jest.resetModules();
44
});
55

6-
test('returns a promise', () => {
6+
test('returns a promise', async () => {
77
const compress = require('../../../lib/gzip/compress');
88

9-
expect(typeof compress('').then).toBe('function');
9+
const result = compress('');
10+
expect(typeof result.then).toBe('function');
11+
await result;
1012
});
1113

1214
test('resolves a promise with Buffer object', async () => {

__tests__/lib/imagemin/compress.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ describe('imagemin compress', () => {
1414
);
1515
const compress = require('../../../lib/imagemin/compress');
1616

17-
expect(typeof compress(input).then).toBe('function');
17+
const result = compress(input);
18+
expect(typeof result.then).toBe('function');
19+
await result;
1820
});
1921

2022
test('resolves a promise with Buffer object', async () => {

__tests__/lib/webp/compress.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ describe('webp compress', () => {
1616
);
1717
const compress = require('../../../lib/webp/compress');
1818

19-
expect(typeof compress(input).then).toBe('function');
19+
const result = compress(input);
20+
expect(typeof result.then).toBe('function');
21+
await result;
2022
});
2123

2224
test('resolves a promise with Buffer object', async () => {

docker/test-node10.Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:10
2+
3+
RUN apt update -y && apt install -y build-essential autoconf automake libjpeg-dev libpng-dev libtiff-dev
4+
5+
ADD package.json yarn.lock /app/
6+
7+
WORKDIR /app
8+
9+
ENV JOBS=max
10+
RUN yarn
11+
12+
ADD . /app/
13+
RUN yarn jest --version; yarn test

lib/gzip/compress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param {Buffer|string} input Buffer instance or string to compress.
77
* @returns {Promise<Buffer>} Promise that resolves with Buffer of compressed input.
88
*/
9-
module.exports = input =>
9+
module.exports = async (input) =>
1010
new Promise((resolve, reject) => {
1111
const { gzip } = require('zlib');
1212

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"scripts": {
1212
"create-package": "docker run --rm -v \"$PWD\":/var/app mageops/aws-lambda-build nodejs-yarn edge-lambda-deploy-package",
1313
"precommit": "lint-staged",
14-
"test": "jest"
14+
"test": "jest",
15+
"test-docker": "docker buildx build --pull -f docker/test-node10.Dockerfile ."
1516
},
1617
"devDependencies": {
1718
"eslint": "^6.8.0",

0 commit comments

Comments
 (0)