refactor: replace Object.assign with spread syntax
This commit is contained in:
@@ -92,7 +92,7 @@ class ProgressBar {
|
||||
const progressBar = new ProgressBar();
|
||||
|
||||
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);
|
||||
let stream: Request = got.stream(url);
|
||||
if (options.progress) {
|
||||
|
||||
+5
-2
@@ -121,9 +121,12 @@ export class Config {
|
||||
}
|
||||
|
||||
afterUpdate() {
|
||||
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
||||
if (this.meta.mobileHeight === null && this.meta.mobileWidth)
|
||||
if (this.meta.mobileWidth === null) {
|
||||
this.meta.mobileWidth = this.meta.width;
|
||||
}
|
||||
if (this.meta.mobileHeight === null && this.meta.mobileWidth) {
|
||||
this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 2.222222222);
|
||||
}
|
||||
}
|
||||
|
||||
branch(params: ConfigParams) {
|
||||
|
||||
+3
-1
@@ -26,7 +26,9 @@ export class Haxe extends Sdk {
|
||||
static VERSION_4_0_2 = "4.0.2";
|
||||
static VERSION_4_0_3 = "4.0.3";
|
||||
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 buildDir = path.join(process.cwd(), "build");
|
||||
|
||||
+3
-1
@@ -44,7 +44,9 @@ export class Neko extends Sdk {
|
||||
static ID = "neko";
|
||||
|
||||
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) {
|
||||
super(Neko.ID, version || Neko.VERSION);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class LinuxDEBPacker extends Packer {
|
||||
const target = this.targetPath;
|
||||
const buildDir = path.join(os.tmpdir(), "build", this.config.name, "debian");
|
||||
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`);
|
||||
fs.writeFileSync(`${buildDir}/usr/share/applications/${this.config.meta.filename}.desktop`, desktop);
|
||||
fse.copySync(`${target}`, `${buildDir}/usr/share/${this.config.meta.filename}/`);
|
||||
|
||||
@@ -35,7 +35,7 @@ export class Preset {
|
||||
public 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 || {};
|
||||
for (const [k, v] of Object.entries(options)) {
|
||||
options[k] = this.fillPreset(v);
|
||||
@@ -55,16 +55,16 @@ export class Preset {
|
||||
}
|
||||
|
||||
compile(): Project[] {
|
||||
const config = new Config(this.options["default"]?.config);
|
||||
if (this.packageInfo.haxeDependencies) {
|
||||
config.update({ libs: this.packageInfo.haxeDependencies });
|
||||
}
|
||||
const config = new Config({
|
||||
meta: { version: this.packageInfo.version },
|
||||
...(this.options["default"]?.config || {}),
|
||||
});
|
||||
const projects: Project[] = [];
|
||||
for (const [k, v] of Object.entries(this.options)) {
|
||||
if (k == "default") {
|
||||
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));
|
||||
}
|
||||
return projects;
|
||||
|
||||
+7
-9
@@ -14,15 +14,13 @@ export class Command {
|
||||
constructor(command: string, options?: any) {
|
||||
this.command = command;
|
||||
this.isWindows = process.platform.lastIndexOf("win") === 0;
|
||||
this.options = Object.assign(
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
verbosity: options && options.silent ? 1 : 2,
|
||||
usePowerShell: false,
|
||||
},
|
||||
options || {},
|
||||
);
|
||||
this.options = {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
verbosity: options?.silent ? 1 : 2,
|
||||
usePowerShell: false,
|
||||
...(options || {}),
|
||||
};
|
||||
|
||||
let previousPath;
|
||||
previousPath = this.options.env.PATH;
|
||||
|
||||
Reference in New Issue
Block a user