-
Notifications
You must be signed in to change notification settings - Fork 420
/
builddmgjsonx86.js
54 lines (46 loc) · 1.41 KB
/
builddmgjsonx86.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const fs = require('fs');
const path = require('path');
const path2 = './OutApp/packages';
// 检查文件夹是否存在
if (!fs.existsSync(path2)) {
// 创建文件夹
fs.mkdirSync(path2, { recursive: true });
console.log(`目录 ${path2} 已创建`);
} else {
console.log(`目录 ${path2} 已存在`);
}
// 配置对象
let config = {
title: 'SysMocap-macOS-x64',
format: "ULMO",
contents: [
{ x: 448, y: 196, type: 'link', path: '/Applications' },
{
x: 192,
y: 196,
type: 'file',
path: '/Users/xianfei/Documents/GitHub/SysMocap/OutApp/SysMocap-darwin-x64/SysMocap.app'
}
],
background: '/Users/xianfei/Documents/GitHub/SysMocap/icons/dmgbg.png',
// icon: '/Users/xianfei/Documents/GitHub/SysMocap/icons/sysmocap.icns',
'icon-size': 80
};
// 获取当前目录
const currentDir = process.cwd();
// 替换路径函数
function replacePath(obj, oldPath, newPath) {
for (let key in obj) {
if (typeof obj[key] === 'string' && obj[key].includes(oldPath)) {
obj[key] = obj[key].replace(oldPath, newPath);
} else if (typeof obj[key] === 'object') {
replacePath(obj[key], oldPath, newPath);
}
}
}
// 替换路径
replacePath(config, '/Users/xianfei/Documents/GitHub/SysMocap', currentDir);
console.log(config);
// 输出新的配置对象
const outputPath = path.join(currentDir, 'dmgcfg.json');
fs.writeFileSync(outputPath, JSON.stringify(config));