Follow the common callback parameter pattern (error, result)

pull/1/head
Alex Beregszaszi 8 years ago
parent d26e762ba8
commit 9b62fc2d22
  1. 14
      src/app/compiler.js

@ -27,8 +27,8 @@ function Compiler (editor, handleGithubCall) {
} }
var internalCompile = function (files, missingInputs) { var internalCompile = function (files, missingInputs) {
gatherImports(files, missingInputs, function (input, error) { gatherImports(files, missingInputs, function (error, input) {
if (input === null) { if (error) {
self.lastCompilationResult = null self.lastCompilationResult = null
self.event.trigger('compilationFinished', [false, { 'error': error }, files]) self.event.trigger('compilationFinished', [false, { 'error': error }, files])
} else { } else {
@ -212,7 +212,7 @@ function Compiler (editor, handleGithubCall) {
function gatherImports (files, importHints, cb) { function gatherImports (files, importHints, cb) {
importHints = importHints || [] importHints = importHints || []
if (!compilerAcceptsMultipleFiles) { if (!compilerAcceptsMultipleFiles) {
cb(files[editor.getCacheFile()]) cb(null, files[editor.getCacheFile()])
return return
} }
// FIXME: This will only match imports if the file begins with one. // FIXME: This will only match imports if the file begins with one.
@ -251,7 +251,7 @@ function Compiler (editor, handleGithubCall) {
} else if ((githubMatch = /^(https?:\/\/)?(www.)?github.com\/([^\/]*\/[^\/]*)\/(.*)/.exec(m))) { } else if ((githubMatch = /^(https?:\/\/)?(www.)?github.com\/([^\/]*\/[^\/]*)\/(.*)/.exec(m))) {
handleGithubCall(githubMatch[3], githubMatch[4], function (err, content) { handleGithubCall(githubMatch[3], githubMatch[4], function (err, content) {
if (err) { if (err) {
cb(null, 'Unable to import "' + m + '": ' + err) cb('Unable to import "' + m + '": ' + err)
return return
} }
@ -262,15 +262,15 @@ function Compiler (editor, handleGithubCall) {
}) })
return return
} else if (/^[^:]*:\/\//.exec(m)) { } else if (/^[^:]*:\/\//.exec(m)) {
cb(null, 'Unable to import "' + m + '": Unsupported URL') cb('Unable to import "' + m + '": Unsupported URL')
return return
} else { } else {
cb(null, 'Unable to import "' + m + '": File not found') cb('Unable to import "' + m + '": File not found')
return return
} }
} }
} while (reloop) } while (reloop)
cb({ 'sources': files }) cb(null, { 'sources': files })
} }
} }

Loading…
Cancel
Save