mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-16 02:03:42 +08:00
Fix broken references to package manager
This commit is contained in:
parent
a4847abb79
commit
f5ad98a516
17 changed files with 24 additions and 37 deletions
|
@ -32,7 +32,7 @@ describe "ThemeManager", ->
|
|||
|
||||
describe "theme getters and setters", ->
|
||||
beforeEach ->
|
||||
NylasEnv.packages.loadPackages()
|
||||
NylasEnv.packages.activatePackage()
|
||||
|
||||
it 'getAvailableThemes get all the loaded themes', ->
|
||||
themes = themeManager.getAvailableThemes()
|
||||
|
|
|
@ -379,12 +379,16 @@ export default class NylasEnvConstructor {
|
|||
|
||||
_findPluginsFromError(error) {
|
||||
if (!error.stack) { return []; }
|
||||
const left = error.stack.match(/((?:\/[\w-_]+)+)/g);
|
||||
const stackPaths = left || [];
|
||||
const stackTokens = _.uniq(_.flatten(stackPaths.map(p => p.split("/"))));
|
||||
const pluginIdsByPathBase = this.packages.getPluginIdsByPathBase();
|
||||
const tokens = _.intersection(Object.keys(pluginIdsByPathBase), stackTokens);
|
||||
return tokens.map(tok => pluginIdsByPathBase[tok]);
|
||||
const stackPaths = error.stack.match(/((?:\/[\w-_]+)+)/g) || [];
|
||||
const stackPathComponents = _.uniq(_.flatten(stackPaths.map(p => p.split("/"))));
|
||||
|
||||
const names = [];
|
||||
for (const pkg of this.packages.getActivePackages()) {
|
||||
if (stackPathComponents.includes(path.basename(pkg.directory))) {
|
||||
names.push(pkg.name);
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -4,6 +4,19 @@ import fs from 'fs-plus';
|
|||
|
||||
const CONFIG_THEME_KEY = 'core.theme';
|
||||
|
||||
/**
|
||||
* The ThemeManager observes the user's theme selection and ensures that
|
||||
* LESS stylesheets in packages are compiled to CSS with the theme's
|
||||
* variables in the @import path. When the theme changes, the ThemeManager
|
||||
* empties it's LESSCache and rebuilds all less stylesheets against the
|
||||
* new theme.
|
||||
*
|
||||
* This class is loosely based on Atom's Theme Manager but:
|
||||
* - Only one theme is active at a time and always overrides ui-light
|
||||
* - Theme packages are never "activated" by the package manager,
|
||||
* they are only placed in the LESS import path.
|
||||
* - ThemeManager directly updates <style> tags when recompiling LESS.
|
||||
*/
|
||||
export default class ThemeManager {
|
||||
constructor({packageManager, resourcePath, configDirPath, safeMode}) {
|
||||
this.packageManager = packageManager;
|
||||
|
@ -116,7 +129,6 @@ export default class ThemeManager {
|
|||
}
|
||||
|
||||
resolveStylesheet(stylesheetPath) {
|
||||
console.log(stylesheetPath);
|
||||
if (path.extname(stylesheetPath).length > 0) {
|
||||
return fs.resolveOnLoadPath(stylesheetPath);
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
Package = require './package'
|
||||
|
||||
module.exports =
|
||||
class ThemePackage extends Package
|
||||
getType: -> 'theme'
|
||||
|
||||
getStyleSheetPriority: -> 1
|
||||
|
||||
enable: ->
|
||||
NylasEnv.themes.setActiveTheme(@name)
|
||||
|
||||
disable: ->
|
||||
NylasEnv.config.removeAtKeyPath('core.themes', @name)
|
||||
|
||||
load: ->
|
||||
@measure 'loadTime', =>
|
||||
try
|
||||
@metadata ?= Package.loadMetadata(@path)
|
||||
catch error
|
||||
console.warn "Failed to load theme named '#{@name}'", error.stack ? error
|
||||
this
|
||||
|
||||
activate: ->
|
||||
unless @isActivated
|
||||
@measure 'activateTime', =>
|
||||
@loadStylesheets()
|
||||
@activateNow()
|
||||
@isActivated = true
|
||||
return Promise.resolve()
|
Loading…
Reference in a new issue