Support --enable-proposed-api through argv.json (#99908)

* Support --enabled-proposed-api thorugh argv.json
Closes #99775

* Fix typos.

* Apply suggestions from code review

Co-authored-by: Benjamin Pasero <benjpas@microsoft.com>

Co-authored-by: Benjamin Pasero <benjpas@microsoft.com>
This commit is contained in:
Jackson Kearl 2020-06-12 01:07:17 -07:00 committed by GitHub
parent 2e2bdd5090
commit 3023198b7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 15 deletions

View file

@ -201,30 +201,45 @@ function configureCommandlineSwitchesSync(cliArgs) {
SUPPORTED_ELECTRON_SWITCHES.push('force-renderer-accessibility');
}
const SUPPORTED_MAIN_PROCESS_SWITCHES = [
// Persistently enable proposed api via argv.json: https://github.com/microsoft/vscode/issues/99775
'enable-proposed-api'
];
// Read argv config
const argvConfig = readArgvConfigSync();
// Append each flag to Electron
Object.keys(argvConfig).forEach(argvKey => {
if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) === -1) {
return; // unsupported argv key
}
const argvValue = argvConfig[argvKey];
// Color profile
if (argvKey === 'force-color-profile') {
if (argvValue) {
app.commandLine.appendSwitch(argvKey, argvValue);
// Append Electron flags to Electron
if (SUPPORTED_ELECTRON_SWITCHES.indexOf(argvKey) !== -1) {
// Color profile
if (argvKey === 'force-color-profile') {
if (argvValue) {
app.commandLine.appendSwitch(argvKey, argvValue);
}
}
// Others
else if (argvValue === true || argvValue === 'true') {
if (argvKey === 'disable-hardware-acceleration') {
app.disableHardwareAcceleration(); // needs to be called explicitly
} else {
app.commandLine.appendSwitch(argvKey);
}
}
}
// Others
else if (argvValue === true || argvValue === 'true') {
if (argvKey === 'disable-hardware-acceleration') {
app.disableHardwareAcceleration(); // needs to be called explicitly
} else {
app.commandLine.appendSwitch(argvKey);
// Append main process flags to process.argv
else if (SUPPORTED_MAIN_PROCESS_SWITCHES.indexOf(argvKey) !== -1) {
if (argvKey === 'enable-proposed-api') {
if (Array.isArray(argvValue)) {
argvValue.forEach(id => id && typeof id === 'string' && process.argv.push('--enable-proposed-api', id));
} else {
console.error(`Unexpected value for \`enable-proposed-api\` in argv.json. Expected array of extension ids.`);
}
}
}
});

View file

@ -343,6 +343,13 @@ import { IJSONSchema } from 'vs/base/common/jsonSchema';
'force-color-profile': {
type: 'string',
markdownDescription: nls.localize('argv.forceColorProfile', 'Allows to override the color profile to use. If you experience colors appear badly, try to set this to `srgb` and restart.')
},
'enable-proposed-api': {
type: 'array',
description: nls.localize('argv.enebleProposedApi', "Enable proposed APIs for a list of extension ids (such as \`vscode.git\`). Proposed APIs are unstable and subject to breaking without warning at any time. This should only be set for extension development and testing purposes."),
items: {
type: 'string'
}
}
}
};