UNPKG

1.17 kBJavaScriptView Raw
1var fs = require('fs');
2var path = require('path');
3var argv = require('yargs').argv;
4
5// Helper to simulate the shell's "cp" command
6function copyFileSync(srcFile, destFile) {
7 var content = fs.readFileSync(srcFile);
8 fs.writeFileSync(destFile, content);
9}
10
11// Copy asset files (specified via process.argv) over to the app binary's folder
12exports.copyAssets = function copyAssets(platform, binPath) {
13 // OS X: Save a custom plist file to Contents/Info.plist in the
14 // app bundle. This lets you customize things like the app's menubar
15 // name and icon (see argv.mac_icon below)
16 if (argv.mac_plist && platform === 'darwin') {
17 var plistPath = path.join(binPath, '..', '..', 'Info.plist');
18 copyFileSync(argv.mac_plist, plistPath);
19 }
20
21 // OS X: Save icon files to the Resources dir in the app bundle.
22 // Note that for the icon to work properly you need to point to
23 // it with a custom plist file.
24 if (argv.mac_icon && platform === 'darwin') {
25 var iconName = path.basename(argv.mac_icon); // Preserve the file's name
26 var iconPath = path.join(binPath, '..', '..', 'Resources', iconName);
27 copyFileSync(argv.mac_icon, iconPath);
28 }
29};