minify error handling
This commit is contained in:
parent
eefe5742c4
commit
85e28d66c1
|
@ -563,6 +563,7 @@ class Article extends ArticleStub {
|
||||||
|
|
||||||
async preProcess( data ) {
|
async preProcess( data ) {
|
||||||
let src
|
let src
|
||||||
|
let out
|
||||||
try {
|
try {
|
||||||
src = cheerio.load( data )
|
src = cheerio.load( data )
|
||||||
} catch ( e ) {
|
} catch ( e ) {
|
||||||
|
@ -619,20 +620,25 @@ class Article extends ArticleStub {
|
||||||
|
|
||||||
this.mimeType = 'text/html'
|
this.mimeType = 'text/html'
|
||||||
this.encoding = 'utf-8'
|
this.encoding = 'utf-8'
|
||||||
const out = dom.html()
|
out = dom.html()
|
||||||
const minified = minify( out, {
|
} catch ( err ) {
|
||||||
|
log( err )
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
out = minify( out, {
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
conservativeCollapse: true,
|
conservativeCollapse: true,
|
||||||
decodeEntities: true,
|
decodeEntities: true,
|
||||||
sortAttributes: true,
|
sortAttributes: true,
|
||||||
sortClassName: true,
|
sortClassName: true,
|
||||||
removeComments: true,
|
removeComments: true,
|
||||||
|
html5: false,
|
||||||
})
|
})
|
||||||
return minified
|
|
||||||
} catch ( err ) {
|
} catch ( err ) {
|
||||||
log( err )
|
log( 'minify', err )
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
transformLink( elem ) {
|
transformLink( elem ) {
|
||||||
|
@ -971,14 +977,14 @@ async function processSamplePage ( samplePageUrl ) {
|
||||||
async function loadPreRequisites () {
|
async function loadPreRequisites () {
|
||||||
const templatePath = command.template ? command.template : osPath.resolve( module.filename, '../stub.html' )
|
const templatePath = command.template ? command.template : osPath.resolve( module.filename, '../stub.html' )
|
||||||
wiki.pageTemplate = await fs.readFile ( templatePath, 'utf8' )
|
wiki.pageTemplate = await fs.readFile ( templatePath, 'utf8' )
|
||||||
|
|
||||||
const removalsPath = osPath.resolve( module.filename, '../removals.txt' )
|
const removalsPath = osPath.resolve( module.filename, '../removals.txt' )
|
||||||
wiki.pageRemovals = command.remove ? command.remove : await fs.readFile ( removalsPath, 'utf8' )
|
wiki.pageRemovals = command.remove ? command.remove : await fs.readFile ( removalsPath, 'utf8' )
|
||||||
|
|
||||||
const css = [ ]
|
const css = [ ]
|
||||||
if ( command.defaultStyle )
|
if ( command.defaultStyle )
|
||||||
css.push( await fs.readFile( osPath.resolve( module.filename, '../stub.css' ), 'utf8' ))
|
css.push( await fs.readFile( osPath.resolve( module.filename, '../stub.css' ), 'utf8' ))
|
||||||
if ( command.style )
|
if ( command.style )
|
||||||
try { // assume that's a file name
|
try { // assume that's a file name
|
||||||
css.push( await fs.readFile( command.style , 'utf8' ))
|
css.push( await fs.readFile( command.style , 'utf8' ))
|
||||||
} catch ( err ) { // treat as a literal
|
} catch ( err ) { // treat as a literal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user