Only require platform stylesheet if it exists

Make requireStylesheet throw exception if the stylesheet does not exist
This commit is contained in:
Kevin Sawicki & Nathan Sobo
2012-08-03 14:56:53 -06:00
committed by Kevin Sawicki
parent 1a8e36d6b7
commit c53f87fcba

View File

@@ -55,8 +55,8 @@ windowAdditions =
$(@rootViewParentSelector).append @rootView
requireStylesheet: (path) ->
fullPath = require.resolve(path)
return unless fs.isFile(fullPath)
unless fullPath = require.resolve(path)
throw new Error("requireStylesheet could not find a file at path '#{path}'")
window.applyStylesheet(fullPath, fs.read(fullPath))
applyStylesheet: (id, text) ->
@@ -107,4 +107,6 @@ require 'underscore-extensions'
requireStylesheet 'reset.css'
requireStylesheet 'atom.css'
requireStylesheet "#{$native.getPlatform()}.css"
if nativeStylesheetPath = require.resolve("#{platform}.css")
requireStylesheet(nativeStylesheetPath)