Skip to content

Commit 8380b87

Browse files
authored
fix: use stat instead of statSync (#14)
1 parent e5d14dd commit 8380b87

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

.github/workflows/nodejs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ on:
88
branches:
99
- main
1010
- master
11+
- 1.x
1112
pull_request:
1213
branches:
1314
- main
1415
- master
16+
- 1.x
1517

1618
jobs:
1719
build:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, 1.x ]
66

77
jobs:
88
release:

lib/object.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs');
2+
const { stat } = require('fs/promises');
23
const is = require('is-type-of');
34
const copy = require('copy-to');
45
const path = require('path');
@@ -59,12 +60,12 @@ proto.put = async function put(name, file, options) {
5960
if (Buffer.isBuffer(file)) {
6061
content = file;
6162
} else if (is.string(file)) {
62-
const stats = fs.statSync(file);
63+
const stats = await stat(file);
6364
if (!stats.isFile()) {
6465
throw new Error(`${file} is not file`);
6566
}
6667
options.mime = options.mime || mime.getType(path.extname(file));
67-
options.contentLength = await this._getFileSize(file);
68+
options.contentLength = stats.size;
6869
const getStream = () => fs.createReadStream(file);
6970
const putStreamStb = (objectName, makeStream, configOption) => {
7071
return this.putStream(objectName, makeStream(), configOption);

0 commit comments

Comments
 (0)