Skip to content

Commit b500107

Browse files
committed
Fix tests
1 parent dee87e5 commit b500107

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/__tests__/s3.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import {
99
generateSyncCriteria,
1010
} from '../s3.js';
1111

12+
function sorter(a: string, b: string) {
13+
if (a < b) {
14+
return -1;
15+
}
16+
if (a > b) {
17+
return 1;
18+
}
19+
return 0;
20+
}
21+
1222
describe('getObjectKeyFromFilePath', () => {
1323
it('should generate the key', () => {
1424
const key = getObjectKeyFromFilePath(
@@ -33,16 +43,19 @@ describe('getObjectKeyFromFilePath', () => {
3343
it('should find files using srcDir and filesGlob', async () => {
3444
const srcDir = './test-fixtures';
3545
const rootDir = path.join(path.resolve(process.cwd()), srcDir);
36-
const files = await getFilesFromSrcDir(srcDir, '**/*.html');
46+
const files = (await getFilesFromSrcDir(srcDir, '**/*.html')).sort(sorter);
3747
expect(files).toEqual([`${rootDir}/blog.html`, `${rootDir}/index.html`]);
3848
});
3949

4050
it('should find files using srcDir and filesGlob with brace expansion', async () => {
4151
const srcDir = './test-fixtures';
4252
const rootDir = path.join(path.resolve(process.cwd()), srcDir);
43-
const files = await getFilesFromSrcDir(srcDir, '{css,site-assets}/**/*');
53+
const files = (
54+
await getFilesFromSrcDir(srcDir, '{css,site-assets,img}/**/*')
55+
).sort(sorter);
4456
expect(files).toEqual([
4557
`${rootDir}/css/styles.css`,
58+
`${rootDir}/img/sample.hdr`,
4659
`${rootDir}/site-assets/script.js`,
4760
]);
4861
});

src/s3.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import path from 'node:path';
22
import fs from 'node:fs';
3-
import util from 'node:util';
43
import mime from 'mime-types';
5-
import glob from 'glob';
4+
import { glob } from 'glob';
65
import { generateETag } from 's3-etag';
76
import {
87
DeleteObjectsCommand,
@@ -17,7 +16,7 @@ import {
1716
} from '@aws-sdk/client-s3';
1817
import { Upload } from '@aws-sdk/lib-storage';
1918
import { debug, info } from '@actions/core';
20-
import minimatch from 'minimatch';
19+
import { minimatch } from 'minimatch';
2120

2221
import { workspace } from './github.js';
2322
import { AsyncBatchQueue } from './AsyncBatchQueue.js';
@@ -235,7 +234,7 @@ export async function getFilesFromSrcDir(
235234
if (srcDir.trim() === '' || filesGlob.trim() === '') {
236235
throw new Error('srcDir and filesGlob must not be empty');
237236
}
238-
return util.promisify(glob)(filesGlob, {
237+
return glob(filesGlob, {
239238
cwd: srcDir,
240239
absolute: true,
241240
nodir: true,

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"strict": true,
88
"noImplicitAny": true,
99
"esModuleInterop": true,
10-
"moduleResolution": "node"
10+
"moduleResolution": "node",
11+
"skipLibCheck": true
1112
},
1213
"exclude": ["node_modules"]
1314
}

0 commit comments

Comments
 (0)