forked from ggchivalrous/yiyin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
26 lines (21 loc) · 712 Bytes
/
Copy pathdev.js
File metadata and controls
26 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import fs from 'fs';
import os from 'os';
import path from 'path';
const __dirname = path.parse(import.meta.url.slice(os.platform() === 'win32' ? 8 : 7)).dir;
async function start() {
const files = fs.readdirSync(path.join(__dirname, 'dist'));
const toPath = path.join(__dirname, 'upload-dist');
console.log('文件列表:', files);
const file = files.find((i) => {
switch (os.platform()) {
case 'darwin': return i.endsWith('.dmg');
case 'win32': return i.endsWith('.exe');
default: return false;
}
});
if (file) {
const filePath = path.join(__dirname, 'dist', file);
fs.copyFileSync(filePath, path.join(toPath, file));
}
}
start().then().catch(console.log);