-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown-image-tool.js
More file actions
38 lines (35 loc) · 1.2 KB
/
markdown-image-tool.js
File metadata and controls
38 lines (35 loc) · 1.2 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
const config = require('./utils/config');
const clipboard = require('./utils/clipboard');
const file = require('./utils/file');
const cloud = require('./utils/cloud');
const countDown = require('./utils/countDown');
process.on('unhandledRejection', (err) => {
console.log('unhandledRejection');
console.log(err);
});
async function main() {
try {
countDown.start();
let localPath = await clipboard.getImageLocalPath();
if (localPath) {
let configJson = await config.get();
let cloudFileName = await file.createName(configJson, localPath);
let link = await cloud.uploadFile(configJson, localPath, cloudFileName);
if (localPath === file.tmpFileName) {
file.deleteTmpFile();
}
await clipboard.copy(``);
console.log('Markdown链接生成并复制成功');
console.log(`耗时 ${countDown.dot(false)}毫秒`);
} else {
console.log('剪切板中没有图片');
}
} catch (err) {
console.log(err);
clipboard.copy(JSON.stringify({
msg: err.msg,
err: err.err.toString()
}));
}
}
main();