Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/debugger-shell/src/electron/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,25 @@

// $FlowFixMe[unclear-type] We have no Flow types for the Electron API.
const {app} = require('electron') as any;
const util = require('util');

// Handle global command line arguments which don't require a window
// or the single instance lock to be held.
const {
values: {version = false},
} = util.parseArgs({
options: {version: {type: 'boolean'}},
args: process.argv.slice(app.isPackaged ? 1 : 2),
strict: false,
});
if (version) {
console.log(`${app.getName()} v${app.getVersion()}`);
// Not app.quit() - we want to exit immediately without initialising the graphical subsystem.
app.exit(0);
}

const gotTheLock = app.requestSingleInstanceLock({
argv: process.argv.slice(2),
argv: process.argv.slice(app.isPackaged ? 1 : 2),
});

if (!gotTheLock) {
Expand Down
23 changes: 23 additions & 0 deletions scripts/debugger-shell/build-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ async function main() {
if (!pkg.main.startsWith('./dist/')) {
throw new Error('Package not built yet. Run scripts/build/build.js first.');
}

const IGNORE_PREFIXES = [
'src',
'dist/node',
'metainternal/build-mac',
'__tests__',
'README.md',
].map(
dirRelativeToPackageRoot =>
path.join(PACKAGE_ROOT, dirRelativeToPackageRoot) + path.sep,
);
const IGNORE_FILES = ['BUCK'].map(fileRelativeToPackageRoot =>
path.join(PACKAGE_ROOT, fileRelativeToPackageRoot),
);

await packager({
dir: PACKAGE_ROOT,
icon: path.join(PACKAGE_ROOT, 'src/electron/resources/icon'),
Expand All @@ -64,6 +79,10 @@ async function main() {
OriginalFilename: `${APP_NAME}.exe`,
},
overwrite: true,
ignore: [
...IGNORE_PREFIXES.map(prefix => new RegExp('^' + escapeRegex(prefix))),
...IGNORE_FILES.map(file => new RegExp('^' + escapeRegex(file) + '$')),
],
});
}

Expand All @@ -73,3 +92,7 @@ if (require.main === module) {
process.exitCode = 1;
});
}

function escapeRegex(str /*: string */) /*: string */ {
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, '\\$&');
}
Loading