20251222
This commit is contained in:
18
AdminPanel/plugins/jsx/utils/cepDir.ts
Normal file
18
AdminPanel/plugins/jsx/utils/cepDir.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { isMac } from "./fs"
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
|
||||
function getUserDataPath() {
|
||||
if (process.platform === 'darwin') {
|
||||
return path.join(os.homedir(), 'Library', 'Application Support');
|
||||
} else if (process.platform === 'win32') {
|
||||
return path.join(process.env.APPDATA);
|
||||
} else {
|
||||
return path.join(os.homedir());
|
||||
}
|
||||
}
|
||||
export function getAdobeCepDir() {
|
||||
const mac = path.join(getUserDataPath(), 'Adobe/CEP/extensions')
|
||||
const win = path.join(getUserDataPath(), 'Adobe/CEP/extensions')
|
||||
return isMac() ? mac : win
|
||||
}
|
||||
25
AdminPanel/plugins/jsx/utils/fs.ts
Normal file
25
AdminPanel/plugins/jsx/utils/fs.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import os from 'os'
|
||||
|
||||
export const copyFolderSync = (from, to) => {
|
||||
if (!fs.existsSync(to)) {
|
||||
fs.mkdirSync(to);
|
||||
}
|
||||
|
||||
fs.readdirSync(from).forEach((element) => {
|
||||
const srcPath = path.join(from, element);
|
||||
const destPath = path.join(to, element);
|
||||
|
||||
if (fs.lstatSync(srcPath).isFile()) {
|
||||
fs.copyFileSync(srcPath, destPath);
|
||||
} else {
|
||||
copyFolderSync(srcPath, destPath);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export function isMac() {
|
||||
return os.platform() === 'darwin'
|
||||
}
|
||||
Reference in New Issue
Block a user