Created
December 22, 2018 10:01
-
-
Save adamdriscoll/dc14d6e35b73909e436bb778e93c57b7 to your computer and use it in GitHub Desktop.
Access VS Code's theme colors programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import stripJsonComments = require('strip-json-comments'); | |
var workbenchSettings = vscode.workspace.getConfiguration("workbench"); | |
var theme = workbenchSettings.colorTheme; | |
var themePath = null; | |
var extension = vscode.extensions.all.find(x => { | |
var extensionTheme = x.packageJSON.contributes.themes && x.packageJSON.contributes.themes.find(y => { | |
return y.label === theme; | |
}); | |
if (extensionTheme != null) { | |
themePath = extensionTheme.path; | |
return true; | |
} | |
return false; | |
}); | |
themePath = path.join(extension.extensionPath, themePath); | |
fs.readFile(themePath, (error, data) => { | |
var themeInfo = JSON.parse(stripJsonComments(data.toString())); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment