mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-17 09:52:29 +01:00
Merge pull request #15309 from twbs/fix-customizer-compile-err-reporting
Catch and properly report compile errors that Less.js's toCSS() can throw
This commit is contained in:
commit
f1102430ec
@ -24,7 +24,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
'<div class="container">' +
|
'<div class="container">' +
|
||||||
'<a href="#bsCustomizerAlert" data-dismiss="alert" class="close pull-right" aria-label="Close" role="button"><span aria-hidden="true">×</span></a>' +
|
'<a href="#bsCustomizerAlert" data-dismiss="alert" class="close pull-right" aria-label="Close" role="button"><span aria-hidden="true">×</span></a>' +
|
||||||
'<p class="bs-customizer-alert-text"><span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span><span class="sr-only">Warning:</span>' + msg + '</p>' +
|
'<p class="bs-customizer-alert-text"><span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span><span class="sr-only">Warning:</span>' + msg + '</p>' +
|
||||||
(err.extract ? '<pre class="bs-customizer-alert-extract">' + err.extract.join('\n') + '</pre>' : '') +
|
(err.message ? $('<p></p>').text('Error: ' + err.message)[0].outerHTML : '') +
|
||||||
|
(err.extract ? $('<pre class="bs-customizer-alert-extract"></pre>').text(err.extract.join('\n'))[0].outerHTML : '') +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>').appendTo('body').alert()
|
'</div>').appendTo('body').alert()
|
||||||
throw err
|
throw err
|
||||||
@ -38,7 +39,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
|
|
||||||
function showCallout(msg, showUpTop) {
|
function showCallout(msg, showUpTop) {
|
||||||
var callout = $('<div class="bs-callout bs-callout-danger">' +
|
var callout = $('<div class="bs-callout bs-callout-danger">' +
|
||||||
'<h4>Attention!</h4>' +
|
'<h4>Attention!</h4>' +
|
||||||
'<p>' + msg + '</p>' +
|
'<p>' + msg + '</p>' +
|
||||||
'</div>')
|
'</div>')
|
||||||
|
|
||||||
@ -258,12 +259,17 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
filename: baseFilename + '.css'
|
filename: baseFilename + '.css'
|
||||||
})
|
})
|
||||||
|
|
||||||
parser.parse(lessSource, function (err, tree) {
|
parser.parse(lessSource, function (parseErr, tree) {
|
||||||
if (err) {
|
if (parseErr) {
|
||||||
return promise.reject(err)
|
return promise.reject(parseErr)
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
intoResult[baseFilename + '.css'] = cw + tree.toCSS()
|
||||||
|
intoResult[baseFilename + '.min.css'] = cw + tree.toCSS({ compress: true })
|
||||||
|
}
|
||||||
|
catch (compileErr) {
|
||||||
|
return promise.reject(compileErr)
|
||||||
}
|
}
|
||||||
intoResult[baseFilename + '.css'] = cw + tree.toCSS()
|
|
||||||
intoResult[baseFilename + '.min.css'] = cw + tree.toCSS({ compress: true })
|
|
||||||
promise.resolve()
|
promise.resolve()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -306,7 +312,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
|
|||||||
}
|
}
|
||||||
promise.resolve(result)
|
promise.resolve(result)
|
||||||
}).fail(function (err) {
|
}).fail(function (err) {
|
||||||
showError('<strong>Ruh roh!</strong> Could not parse less files.', err)
|
showError('<strong>Ruh roh!</strong> Problem parsing or compiling Less files.', err)
|
||||||
promise.reject()
|
promise.reject()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user