Support binary Info.plist (#41)
This commit is contained in:
parent
4f80ea2d80
commit
5eb1c69420
21
cli.js
21
cli.js
|
@ -47,9 +47,11 @@ if (!destPath) {
|
|||
destPath = process.cwd();
|
||||
}
|
||||
|
||||
const infoPlistPath = path.join(appPath, 'Contents/Info.plist');
|
||||
|
||||
let infoPlist;
|
||||
try {
|
||||
infoPlist = fs.readFileSync(path.join(appPath, 'Contents/Info.plist'), 'utf8');
|
||||
infoPlist = fs.readFileSync(infoPlistPath, 'utf8');
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
console.error(`Could not find \`${path.relative(process.cwd(), appPath)}\``);
|
||||
|
@ -59,15 +61,22 @@ try {
|
|||
throw error;
|
||||
}
|
||||
|
||||
const appInfo = plist.parse(infoPlist);
|
||||
const appName = appInfo.CFBundleDisplayName || appInfo.CFBundleName;
|
||||
const appIconName = appInfo.CFBundleIconFile.replace(/\.icns/, '');
|
||||
const dmgPath = path.join(destPath, `${appName} ${appInfo.CFBundleShortVersionString}.dmg`);
|
||||
|
||||
const ora = new Ora('Creating DMG');
|
||||
ora.start();
|
||||
|
||||
async function init() {
|
||||
let appInfo;
|
||||
try {
|
||||
appInfo = plist.parse(infoPlist);
|
||||
} catch (_) {
|
||||
const {stdout} = await execa('plutil', ['-convert', 'xml1', '-o', '-', infoPlistPath]);
|
||||
appInfo = plist.parse(stdout);
|
||||
}
|
||||
|
||||
const appName = appInfo.CFBundleDisplayName || appInfo.CFBundleName;
|
||||
const appIconName = appInfo.CFBundleIconFile.replace(/\.icns/, '');
|
||||
const dmgPath = path.join(destPath, `${appName} ${appInfo.CFBundleShortVersionString}.dmg`);
|
||||
|
||||
if (cli.flags.overwrite) {
|
||||
try {
|
||||
fs.unlinkSync(dmgPath);
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
APPL????
|
Binary file not shown.
BIN
fixture-with-binary-plist.app/Contents/Resources/English.lproj/MainMenu.nib
generated
Normal file
BIN
fixture-with-binary-plist.app/Contents/Resources/English.lproj/MainMenu.nib
generated
Normal file
Binary file not shown.
Binary file not shown.
17
test.js
17
test.js
|
@ -11,7 +11,22 @@ test('main', async t => {
|
|||
await execa(path.join(__dirname, 'cli.js'), [path.join(__dirname, 'fixture.app')], {cwd});
|
||||
} catch (error) {
|
||||
// Silence code signing failure
|
||||
if (!/Code signing failed/.test(error.message)) {
|
||||
if (!error.message.includes('Code signing failed')) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
t.true(fs.existsSync(path.join(cwd, 'Fixture 0.0.1.dmg')));
|
||||
});
|
||||
|
||||
test('binary plist', async t => {
|
||||
const cwd = tempy.directory();
|
||||
|
||||
try {
|
||||
await execa(path.join(__dirname, 'cli.js'), [path.join(__dirname, 'fixture-with-binary-plist.app')], {cwd});
|
||||
} catch (error) {
|
||||
// Silence code signing failure
|
||||
if (!error.message.includes('Code signing failed')) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue