forked from olcxjas-softworks/LarpixClient
update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
89
electron/node_modules/builder-util/out/fs.js
generated
vendored
89
electron/node_modules/builder-util/out/fs.js
generated
vendored
|
|
@ -1,17 +1,23 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.USE_HARD_LINKS = exports.DO_NOT_USE_HARD_LINKS = exports.copyDir = exports.FileCopier = exports.copyOrLinkFile = exports.copyFile = exports.walk = exports.exists = exports.statOrNull = exports.unlinkIfExists = exports.CopyFileTransformer = exports.CONCURRENCY = exports.MAX_FILE_REQUESTS = void 0;
|
||||
const bluebird_lst_1 = require("bluebird-lst");
|
||||
exports.USE_HARD_LINKS = exports.DO_NOT_USE_HARD_LINKS = exports.FileCopier = exports.CopyFileTransformer = exports.MAX_FILE_REQUESTS = void 0;
|
||||
exports.unlinkIfExists = unlinkIfExists;
|
||||
exports.statOrNull = statOrNull;
|
||||
exports.exists = exists;
|
||||
exports.walk = walk;
|
||||
exports.copyFile = copyFile;
|
||||
exports.copyOrLinkFile = copyOrLinkFile;
|
||||
exports.copyDir = copyDir;
|
||||
exports.dirSize = dirSize;
|
||||
const fs_extra_1 = require("fs-extra");
|
||||
const os_1 = require("os");
|
||||
const promises_1 = require("fs/promises");
|
||||
const os_1 = require("os");
|
||||
const path = require("path");
|
||||
const stat_mode_1 = require("stat-mode");
|
||||
const tiny_async_pool_1 = require("tiny-async-pool");
|
||||
const log_1 = require("./log");
|
||||
const promise_1 = require("./promise");
|
||||
const isCI = require("is-ci");
|
||||
exports.MAX_FILE_REQUESTS = 8;
|
||||
exports.CONCURRENCY = { concurrency: exports.MAX_FILE_REQUESTS };
|
||||
class CopyFileTransformer {
|
||||
constructor(afterCopyTransformer) {
|
||||
this.afterCopyTransformer = afterCopyTransformer;
|
||||
|
|
@ -19,25 +25,22 @@ class CopyFileTransformer {
|
|||
}
|
||||
exports.CopyFileTransformer = CopyFileTransformer;
|
||||
function unlinkIfExists(file) {
|
||||
return promises_1.unlink(file).catch(() => {
|
||||
return (0, promises_1.unlink)(file).catch(() => {
|
||||
/* ignore */
|
||||
});
|
||||
}
|
||||
exports.unlinkIfExists = unlinkIfExists;
|
||||
async function statOrNull(file) {
|
||||
return promise_1.orNullIfFileNotExist(promises_1.stat(file));
|
||||
return (0, promise_1.orNullIfFileNotExist)((0, promises_1.stat)(file));
|
||||
}
|
||||
exports.statOrNull = statOrNull;
|
||||
async function exists(file) {
|
||||
try {
|
||||
await promises_1.access(file);
|
||||
await (0, promises_1.access)(file);
|
||||
return true;
|
||||
}
|
||||
catch (e) {
|
||||
catch (_e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.exists = exists;
|
||||
/**
|
||||
* Returns list of file paths (system-dependent file separator)
|
||||
*/
|
||||
|
|
@ -56,25 +59,25 @@ async function walk(initialDirPath, filter, consumer) {
|
|||
addDirToResult = true;
|
||||
}
|
||||
}
|
||||
const childNames = await promise_1.orIfFileNotExist(promises_1.readdir(dirPath), []);
|
||||
const childNames = await (0, promise_1.orIfFileNotExist)((0, promises_1.readdir)(dirPath), []);
|
||||
childNames.sort();
|
||||
let nodeModuleContent = null;
|
||||
const dirs = [];
|
||||
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
|
||||
const sortedFilePaths = await bluebird_lst_1.default.map(childNames, name => {
|
||||
const sortedFilePaths = await (0, tiny_async_pool_1.default)(exports.MAX_FILE_REQUESTS, childNames, async (name) => {
|
||||
if (name === ".DS_Store" || name === ".gitkeep") {
|
||||
return null;
|
||||
}
|
||||
const filePath = dirPath + path.sep + name;
|
||||
return promises_1.lstat(filePath).then(stat => {
|
||||
return (0, promises_1.lstat)(filePath).then(stat => {
|
||||
if (filter != null && !filter(filePath, stat)) {
|
||||
return null;
|
||||
}
|
||||
const consumerResult = consumer == null ? null : consumer.consume(filePath, stat, dirPath, childNames);
|
||||
if (consumerResult === false) {
|
||||
if (consumerResult === true) {
|
||||
return null;
|
||||
}
|
||||
else if (consumerResult == null || !("then" in consumerResult)) {
|
||||
else if (consumerResult === false || consumerResult == null || !("then" in consumerResult)) {
|
||||
if (stat.isDirectory()) {
|
||||
dirs.push(name);
|
||||
return null;
|
||||
|
|
@ -100,7 +103,7 @@ async function walk(initialDirPath, filter, consumer) {
|
|||
});
|
||||
}
|
||||
});
|
||||
}, exports.CONCURRENCY);
|
||||
});
|
||||
for (const child of sortedFilePaths) {
|
||||
if (child != null) {
|
||||
result.push(child);
|
||||
|
|
@ -116,12 +119,13 @@ async function walk(initialDirPath, filter, consumer) {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
exports.walk = walk;
|
||||
const _isUseHardLink = process.platform !== "win32" && process.env.USE_HARD_LINKS !== "false" && (isCI || process.env.USE_HARD_LINKS === "true");
|
||||
// performance optimization. only enable hard links during unit tests on non-Windows platforms by default
|
||||
// This is to optimize disk space and speed during tests, while avoiding potential issues with hard links in distribution builds
|
||||
// https://github.com/electron-userland/electron-builder/issues/5721
|
||||
const _isUseHardLink = process.platform !== "win32" && (process.env.USE_HARD_LINKS === "true" || process.env.VITEST != null);
|
||||
function copyFile(src, dest, isEnsureDir = true) {
|
||||
return (isEnsureDir ? promises_1.mkdir(path.dirname(dest), { recursive: true }) : Promise.resolve()).then(() => copyOrLinkFile(src, dest, null, false));
|
||||
return (isEnsureDir ? (0, promises_1.mkdir)(path.dirname(dest), { recursive: true }) : Promise.resolve()).then(() => copyOrLinkFile(src, dest, null, false));
|
||||
}
|
||||
exports.copyFile = copyFile;
|
||||
/**
|
||||
* Hard links is used if supported and allowed.
|
||||
* File permission is fixed — allow execute for all if owner can, allow read for all if owner can.
|
||||
|
|
@ -158,7 +162,7 @@ function copyOrLinkFile(src, dest, stats, isUseHardLink, exDevErrorHandler) {
|
|||
}
|
||||
}
|
||||
if (isUseHardLink) {
|
||||
return promises_1.link(src, dest).catch(e => {
|
||||
return (0, promises_1.link)(src, dest).catch((e) => {
|
||||
if (e.code === "EXDEV") {
|
||||
const isLog = exDevErrorHandler == null ? true : exDevErrorHandler();
|
||||
if (isLog && log_1.log.isDebugEnabled) {
|
||||
|
|
@ -173,13 +177,12 @@ function copyOrLinkFile(src, dest, stats, isUseHardLink, exDevErrorHandler) {
|
|||
}
|
||||
return doCopyFile(src, dest, stats);
|
||||
}
|
||||
exports.copyOrLinkFile = copyOrLinkFile;
|
||||
function doCopyFile(src, dest, stats) {
|
||||
const promise = fs_extra_1.copyFile(src, dest);
|
||||
const promise = (0, fs_extra_1.copyFile)(src, dest);
|
||||
if (stats == null) {
|
||||
return promise;
|
||||
}
|
||||
return promise.then(() => promises_1.chmod(dest, stats.mode));
|
||||
return promise.then(() => (0, promises_1.chmod)(dest, stats.mode));
|
||||
}
|
||||
class FileCopier {
|
||||
constructor(isUseHardLinkFunction, transformer) {
|
||||
|
|
@ -205,7 +208,7 @@ class FileCopier {
|
|||
afterCopyTransformer = data.afterCopyTransformer;
|
||||
}
|
||||
else {
|
||||
await promises_1.writeFile(dest, data);
|
||||
await (0, promises_1.writeFile)(dest, data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -234,21 +237,19 @@ exports.FileCopier = FileCopier;
|
|||
* Empty directories is never created.
|
||||
* Hard links is used if supported and allowed.
|
||||
*/
|
||||
function copyDir(src, destination, options = {}) {
|
||||
async function copyDir(src, destination, options = {}) {
|
||||
const fileCopier = new FileCopier(options.isUseHardLink, options.transformer);
|
||||
if (log_1.log.isDebugEnabled) {
|
||||
log_1.log.debug({ src, destination }, `copying${fileCopier.isUseHardLink ? " using hard links" : ""}`);
|
||||
}
|
||||
log_1.log.debug({ src, destination }, `copying${fileCopier.isUseHardLink ? " using hard links" : ""}`);
|
||||
const createdSourceDirs = new Set();
|
||||
const links = [];
|
||||
const symlinkType = os_1.platform() === "win32" ? "junction" : "file";
|
||||
return walk(src, options.filter, {
|
||||
const symlinkType = (0, os_1.platform)() === "win32" ? "junction" : "file";
|
||||
return await walk(src, options.filter, {
|
||||
consume: async (file, stat, parent) => {
|
||||
if (!stat.isFile() && !stat.isSymbolicLink()) {
|
||||
return;
|
||||
}
|
||||
if (!createdSourceDirs.has(parent)) {
|
||||
await promises_1.mkdir(parent.replace(src, destination), { recursive: true });
|
||||
await (0, promises_1.mkdir)(parent.replace(src, destination), { recursive: true });
|
||||
createdSourceDirs.add(parent);
|
||||
}
|
||||
const destFile = file.replace(src, destination);
|
||||
|
|
@ -256,12 +257,26 @@ function copyDir(src, destination, options = {}) {
|
|||
await fileCopier.copy(file, destFile, stat);
|
||||
}
|
||||
else {
|
||||
links.push({ file: destFile, link: await promises_1.readlink(file) });
|
||||
links.push({ file: destFile, link: await (0, promises_1.readlink)(file) });
|
||||
}
|
||||
},
|
||||
}).then(() => bluebird_lst_1.default.map(links, it => promises_1.symlink(it.link, it.file, symlinkType), exports.CONCURRENCY));
|
||||
}).then(() => (0, tiny_async_pool_1.default)(exports.MAX_FILE_REQUESTS, links, it => (0, promises_1.symlink)(it.link, it.file, symlinkType)));
|
||||
}
|
||||
async function dirSize(dirPath) {
|
||||
const entries = await (0, promises_1.readdir)(dirPath, { withFileTypes: true });
|
||||
const entrySizes = entries.map(async (entry) => {
|
||||
const entryPath = path.join(dirPath, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
return await dirSize(entryPath);
|
||||
}
|
||||
if (entry.isFile()) {
|
||||
const { size } = await (0, promises_1.stat)(entryPath);
|
||||
return size;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return (await Promise.all(entrySizes)).reduce((entrySize, totalSize) => entrySize + totalSize, 0);
|
||||
}
|
||||
exports.copyDir = copyDir;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const DO_NOT_USE_HARD_LINKS = (file) => false;
|
||||
exports.DO_NOT_USE_HARD_LINKS = DO_NOT_USE_HARD_LINKS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue