HJ_Client/extensions/my_builder/dist/fixFiles.js
DESKTOP-15R5JU0\legu 62fef0360c init
2023-11-17 14:13:11 +08:00

39 lines
1.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixFiles = void 0;
const fs_1 = require("fs");
const path_1 = require("path");
const fixFiles = async function (options, result) {
const fixPath = (0, path_1.join)(Editor.Project.path, `buildAssets/fix/${options.platform}`);
const resultPath = result.dest;
if (!(0, fs_1.existsSync)(fixPath))
return;
const loop = (depth) => {
let f = (0, path_1.join)(fixPath, depth);
let r = (0, path_1.join)(resultPath, depth);
(0, fs_1.readdirSync)(f).forEach(file => {
let fFile = (0, path_1.join)(f, file);
let rFile = (0, path_1.join)(r, file);
if ((0, fs_1.statSync)(fFile).isDirectory()) {
if (!(0, fs_1.existsSync)(rFile))
(0, fs_1.mkdirSync)(rFile);
loop(depth + '/' + file);
}
else {
let c = (0, fs_1.readdirSync)(r).filter(_r => {
let a = _r.split('.');
return [a[0], a.slice(a.length - 1)].join('.') == file;
});
if (c[0]) {
(0, fs_1.writeFileSync)((0, path_1.join)(r, c[0]), (0, fs_1.readFileSync)(fFile));
}
else {
(0, fs_1.writeFileSync)(rFile, (0, fs_1.readFileSync)(fFile));
}
}
});
};
loop('');
};
exports.fixFiles = fixFiles;