Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(Builder): fix fixMacMeta for later NW.js versions
Browse files Browse the repository at this point in the history
  • Loading branch information
evshiron committed Apr 21, 2017
1 parent 724472e commit a4d0563
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/Builder.ts
Expand Up @@ -224,9 +224,13 @@ export class Builder {

const path = resolve(targetDir, file);

const strings = <string>(await readFileAsync(path, {
encoding: 'ucs2',
}));
// Different versions has different encodings for `InforPlist.strings`.
// We determine encoding by evaluating bytes of `CF` here.
const data = await readFileAsync(path);
const encoding = data.indexOf(Buffer.from('43004600', 'hex')) >= 0
? 'ucs2' : 'utf-8';

const strings = data.toString(encoding);

const newStrings = strings.replace(/([A-Za-z]+)\s+=\s+"(.+?)";/g, (match: string, key: string, value: string) => {
switch(key) {
Expand All @@ -245,7 +249,7 @@ export class Builder {
}
});

await writeFileAsync(path, Buffer.from(newStrings, 'ucs2'));
await writeFileAsync(path, Buffer.from(newStrings, encoding));

}

Expand Down

0 comments on commit a4d0563

Please sign in to comment.