Skip to content

Commit

Permalink
Switching to japanese for dmg-license tests since russian does not ha…
Browse files Browse the repository at this point in the history
…ve a default label
  • Loading branch information
Mike Maietta committed Dec 2, 2020
1 parent 1b8ea4f commit 5b7e9bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions packages/dmg-builder/src/dmgLicense.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { exec, log } from "builder-util"
import { safeLoad } from 'js-yaml'
import { PlatformPackager } from "app-builder-lib"
import { getLicenseFiles } from "app-builder-lib/out/util/license"
import { outputFile, readFile, readJson } from "fs-extra"
Expand All @@ -9,6 +10,8 @@ import { dmgLicenseFromJSON } from 'dmg-license'
// DropDMG/dmgbuild a in any case (even if no english, but only ru/de) set to 0 (en_US), well, without docs, just believe that's correct
const DEFAULT_REGION_CODE = 0

// License Specifications
// https://github.com/argv-minus-one/dmg-license/blob/HEAD/docs/License%20Specifications.md
type LicenseConfig = {
'$schema': string
body: any[]
Expand All @@ -26,7 +29,7 @@ export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath:
packager.debugLogger.add("dmg.licenseButtons", licenseButtonFiles)

const jsonFile: LicenseConfig = {
'$schema': 'https://github.com/argv-minus-one/dmg-license/raw/master/schema.json',
"$schema": "https://github.com/argv-minus-one/dmg-license/raw/master/schema.json",
// defaultLang: '',
body: [],
labels: []
Expand All @@ -40,7 +43,8 @@ export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath:
}

for (const button of licenseButtonFiles) {
const label = await readJson(button.file)
const filepath = button.file
const label = filepath.endsWith(".yml") ? safeLoad(await readFile(filepath, "utf-8")) : await readJson(filepath)
if (label.description) {
// to support original button file format
label.message = label.description
Expand Down
8 changes: 4 additions & 4 deletions test/snapshots/mac/dmgTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ Object {
}
`;

exports[`license rtf 1`] = `
exports[`license ja 1`] = `
Object {
"mac": Array [
Object {
Expand All @@ -2496,7 +2496,7 @@ Object {
}
`;

exports[`license rtf 2`] = `
exports[`license ja 2`] = `
Object {
"CFBundleDisplayName": "Test App ßW",
"CFBundleExecutable": "Test App ßW",
Expand Down Expand Up @@ -2532,7 +2532,7 @@ Object {
}
`;

exports[`license ru 1`] = `
exports[`license rtf 1`] = `
Object {
"mac": Array [
Object {
Expand All @@ -2556,7 +2556,7 @@ Object {
}
`;

exports[`license ru 2`] = `
exports[`license rtf 2`] = `
Object {
"CFBundleDisplayName": "Test App ßW",
"CFBundleExecutable": "Test App ßW",
Expand Down
6 changes: 3 additions & 3 deletions test/src/mac/dmgTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ test.ifAll.ifMac("multi language license", app(packagerOptions, {
return Promise.all([
// writeFile(path.join(projectDir, "build", "license_en.txt"), "Hi"),
fs.writeFile(path.join(projectDir, "build", "license_de.txt"), "Hallo"),
fs.writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет"),
fs.writeFile(path.join(projectDir, "build", "license_ja.txt"), "こんにちは"),
])
},
}))

test.ifAll.ifMac("license ru", app(packagerOptions, {
test.ifAll.ifMac("license ja", app(packagerOptions, {
projectDirCreated: projectDir => {
return fs.writeFile(path.join(projectDir, "build", "license_ru.txt"), "Привет".repeat(12))
return fs.writeFile(path.join(projectDir, "build", "license_ja.txt"), "こんにちは".repeat(12))
},
}))

Expand Down

0 comments on commit 5b7e9bd

Please sign in to comment.