-
Notifications
You must be signed in to change notification settings - Fork 1
fix: patch File to support test on Node.js 18 #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ test/node/.tmp | |
| test/demo.js | ||
| yarn.lock | ||
| package-lock.json | ||
| pnpm-lock.yaml | ||
| .nyc_output/ | ||
| .env | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const { OSSObject } = require('..'); | ||
|
|
||
| const ossObject = new OSSObject({ | ||
| region: 'oss-cn-hangzhou', | ||
| endpoint: 'https://oss-cn-hangzhou.aliyuncs.com', | ||
| accessKeyId: 'LTAI5tG666666666666666', | ||
| accessKeySecret: '66666666666666666666666666666666', | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bucket: 'foo', | ||
|
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid hardcoded secrets and logging sensitive config Even as placeholders, committing credentials and logging the constructed client can leak secrets if envs are used later. Use env vars with safe fallbacks and avoid logging the full object. - accessKeyId: 'LTAI5tG666666666666666',
- accessKeySecret: '66666666666666666666666666666666',
+ accessKeyId: process.env.OSS_ACCESS_KEY_ID || 'test-ak',
+ accessKeySecret: process.env.OSS_ACCESS_KEY_SECRET || 'test-secret',
@@
-console.log(ossObject);
+require('node:assert').ok(ossObject);Also applies to: 11-11 🤖 Prompt for AI Agents |
||
| }); | ||
|
|
||
| console.log(ossObject); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { File } from 'node:buffer'; | ||
|
|
||
| // multi undici version in node version less than 20 https://github.com/nodejs/undici/issues/4374 | ||
| if (typeof global.File === 'undefined') { | ||
| // @ts-ignore | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| global.File = File; | ||
| } | ||
fengmk2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineConfig } from 'vitest/config'; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| setupFiles: ['test/setup.ts'], | ||
| }, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.