refactor: replace Object.assign with spread syntax

This commit is contained in:
2026-10-29 01:17:10 +03:00
parent 05be4ab622
commit f417fcac73
8 changed files with 30 additions and 27 deletions
+4 -6
View File
@@ -9,14 +9,12 @@
"icon": "./resources/icon.jpg", "icon": "./resources/icon.jpg",
"pack": "com.example", "pack": "com.example",
"author": "Anonim <anonim@anonim.com>", "author": "Anonim <anonim@anonim.com>",
"company": "Any company", "company": "Any company"
"version": "<%=package.version%>"
}, },
"haxe": "4.2.5",
"libs": { "libs": {
"lime": "8.0.0", "lime": "8.3.2",
"openfl": "9.2.0", "openfl": "9.5.2",
"hxcpp": "4.2.1" "hxcpp": "4.3.2"
}, },
"sources": ["src"], "sources": ["src"],
"main": "Main" "main": "Main"
+1 -1
View File
@@ -92,7 +92,7 @@ class ProgressBar {
const progressBar = new ProgressBar(); const progressBar = new ProgressBar();
export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => { export const download = async (url: string, dest: string, options?: DownloadOptions): Promise<void> => {
options = Object.assign({}, DEFAULT_OPTIONS, options); options = { ...DEFAULT_OPTIONS, ...options };
fse.ensureDirSync(dest); fse.ensureDirSync(dest);
let stream: Request = got.stream(url); let stream: Request = got.stream(url);
if (options.progress) { if (options.progress) {
+5 -2
View File
@@ -121,9 +121,12 @@ export class Config {
} }
afterUpdate() { afterUpdate() {
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width; if (this.meta.mobileWidth === null) {
if (this.meta.mobileHeight === null && this.meta.mobileWidth) this.meta.mobileWidth = this.meta.width;
}
if (this.meta.mobileHeight === null && this.meta.mobileWidth) {
this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222); this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
}
} }
branch(params: ConfigParams) { branch(params: ConfigParams) {
+3 -1
View File
@@ -26,7 +26,9 @@ export class Haxe extends Sdk {
static VERSION_4_0_2 = "4.0.2"; static VERSION_4_0_2 = "4.0.2";
static VERSION_4_0_3 = "4.0.3"; static VERSION_4_0_3 = "4.0.3";
static VERSION_4_0_5 = "4.0.5"; static VERSION_4_0_5 = "4.0.5";
static VERSION_4 = Haxe.VERSION_4_0_5; static VERSION_4_2_5 = "4.2.5";
static VERSION_4_3_7 = "4.3.7";
static VERSION_4 = Haxe.VERSION_4_3_7;
static VERSION = Haxe.VERSION_4; static VERSION = Haxe.VERSION_4;
static buildDir = path.join(process.cwd(), "build"); static buildDir = path.join(process.cwd(), "build");
+3 -1
View File
@@ -44,7 +44,9 @@ export class Neko extends Sdk {
static ID = "neko"; static ID = "neko";
static VERSION_2_2_0 = "2.2.0"; static VERSION_2_2_0 = "2.2.0";
static VERSION = Neko.VERSION_2_2_0; static VERSION_2_4_0 = "2.4.0";
static VERSION_2_4_1 = "2.4.1";
static VERSION = Neko.VERSION_2_4_1;
constructor(version?: string) { constructor(version?: string) {
super(Neko.ID, version || Neko.VERSION); super(Neko.ID, version || Neko.VERSION);
+1 -1
View File
@@ -20,7 +20,7 @@ export class LinuxDEBPacker extends Packer {
const target = this.targetPath; const target = this.targetPath;
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian"); const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`; const iconfile = `${this.config.meta.filename}${path.extname(this.config.meta.icon!)}`;
const desktop = template.render("linux/app.desktop", Object.assign({ iconfile: iconfile }, this.config)); const desktop = template.render("linux/app.desktop", { iconfile: iconfile, ...this.config });
fse.ensureDirSync(`${buildDir}/usr/share/applications`); fse.ensureDirSync(`${buildDir}/usr/share/applications`);
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop); fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`); fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
+6 -6
View File
@@ -35,7 +35,7 @@ export class Preset {
public packageInfo: Record<string, any>; public packageInfo: Record<string, any>;
constructor(options: Record<string, ProjectPreset>, config?: PresetConfig, packageInfo?: Record<string, any>) { constructor(options: Record<string, ProjectPreset>, config?: PresetConfig, packageInfo?: Record<string, any>) {
this.config = Object.assign(DEFAULT_CONFIG, config || {}); this.config = { ...DEFAULT_CONFIG, ...(config || {}) };
this.packageInfo = packageInfo || {}; this.packageInfo = packageInfo || {};
for (const [k, v] of Object.entries(options)) { for (const [k, v] of Object.entries(options)) {
options[k] = this.fillPreset(v); options[k] = this.fillPreset(v);
@@ -55,16 +55,16 @@ export class Preset {
} }
compile(): Project[] { compile(): Project[] {
const config = new Config(this.options["default"]?.config); const config = new Config({
if (this.packageInfo.haxeDependencies) { meta: { version: this.packageInfo.version },
config.update({ libs: this.packageInfo.haxeDependencies }); ...(this.options["default"]?.config || {}),
} });
const projects: Project[] = []; const projects: Project[] = [];
for (const [k, v] of Object.entries(this.options)) { for (const [k, v] of Object.entries(this.options)) {
if (k == "default") { if (k == "default") {
continue; continue;
} }
const projectConfig = config.branch(Object.assign(v.config, { name: k })); const projectConfig = config.branch({ ...v.config, name: k });
projects.push(new Project(v.buildSystem!, v.platforms!, projectConfig)); projects.push(new Project(v.buildSystem!, v.platforms!, projectConfig));
} }
return projects; return projects;
+7 -9
View File
@@ -14,15 +14,13 @@ export class Command {
constructor(command: string, options?: any) { constructor(command: string, options?: any) {
this.command = command; this.command = command;
this.isWindows = process.platform.lastIndexOf("win") === 0; this.isWindows = process.platform.lastIndexOf("win") === 0;
this.options = Object.assign( this.options = {
{ cwd: process.cwd(),
cwd: process.cwd(), env: process.env,
env: process.env, verbosity: options?.silent ? 1 : 2,
verbosity: options && options.silent ? 1 : 2, usePowerShell: false,
usePowerShell: false, ...(options || {}),
}, };
options || {},
);
let previousPath; let previousPath;
previousPath = this.options.env.PATH; previousPath = this.options.env.PATH;