feat: 添加测试更新相关代码
This commit is contained in:
1 parent
24f910e12c
commit
f4e4d8c8f7
4 files changed
+53
-1
No files matched your search
@@ -0,0 +1,18 @@
|
||||
import fs from 'fs';
|
||||
import { exec } from 'child_process';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const data = await readFormData(event)
|
||||
const file = data.get('file') as File
|
||||
const buffer = await file.arrayBuffer()
|
||||
const uint8Array = new Uint8Array(buffer)
|
||||
fs.writeFileSync('./userData/test.txt', uint8Array, {
|
||||
flag: 'w',
|
||||
})
|
||||
setTimeout(() => {
|
||||
exec('nohup sh ./update.sh > update.nohup.log 2>&1 &')
|
||||
}, 500)
|
||||
return {
|
||||
status: 200,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
import fs from 'fs';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const data = await readFormData(event)
|
||||
const file = data.get('file') as File
|
||||
const buffer = await file.arrayBuffer()
|
||||
const uint8Array = new Uint8Array(buffer)
|
||||
fs.writeFileSync('./userData/test.txt', uint8Array, {
|
||||
flag: 'w',
|
||||
})
|
||||
return {
|
||||
status: 200,
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user