diff --git a/tasks/.jshintrc b/tasks/.jshintrc new file mode 100644 index 0000000000..143ea62260 --- /dev/null +++ b/tasks/.jshintrc @@ -0,0 +1,19 @@ +{ + "curly": true, + "eqeqeq": true, + "indent": 2, + "latedef": true, + "newcap": true, + "nonew": true, + "quotmark": "single", + "undef": true, + "trailing": true, + "maxlen": 80, + "globals": { + "__dirname": false, + "exports": true, + "module": false, + "process": false, + "require": false + } +} diff --git a/tasks/generate-exports.js b/tasks/generate-exports.js index 95afa890f9..5547758384 100644 --- a/tasks/generate-exports.js +++ b/tasks/generate-exports.js @@ -26,8 +26,8 @@ function getConfig(configPath, callback) { var obj; try { obj = JSON.parse(String(data)); - } catch (err) { - callback(new Error('Trouble parsing file as JSON: ' + options.config)); + } catch (err2) { + callback(new Error('Trouble parsing file as JSON: ' + configPath)); return; } var patterns = obj.exports; @@ -224,7 +224,7 @@ if (require.main === module) { fse.outputFile.bind(fse, options.output) ], function(err) { if (err) { - console.error(err.message); + process.stderr.write(err.message + '\n'); process.exit(1); } else { process.exit(0); diff --git a/tasks/generate-info.js b/tasks/generate-info.js index 7f6832115b..e038d348f2 100644 --- a/tasks/generate-info.js +++ b/tasks/generate-info.js @@ -97,6 +97,33 @@ function getNewer(date, newer, callback) { } +/** + * Parse the JSDoc output. + * @param {string} output JSDoc output + * @return {Object} Symbol and define info. + */ +function parseOutput(output) { + if (!output) { + throw new Error('Expected JSON output'); + } + + var info; + try { + info = JSON.parse(String(output)); + } catch (err) { + throw new Error('Failed to parse output as JSON: ' + output); + } + if (!Array.isArray(info.symbols)) { + throw new Error('Expected symbols array: ' + output); + } + if (!Array.isArray(info.defines)) { + throw new Error('Expected defines array: ' + output); + } + + return info; +} + + /** * Spawn JSDoc. * @param {Array.} paths Paths to source files. @@ -142,33 +169,6 @@ function spawnJSDoc(paths, callback) { } -/** - * Parse the JSDoc output. - * @param {string} output JSDoc output - * @return {Object} Symbol and define info. - */ -function parseOutput(output) { - if (!output) { - throw new Error('Expected JSON output'); - } - - var info; - try { - info = JSON.parse(String(output)); - } catch (err) { - throw new Error('Failed to parse output as JSON: ' + output); - } - if (!Array.isArray(info.symbols)) { - throw new Error('Expected symbols array: ' + output); - } - if (!Array.isArray(info.defines)) { - throw new Error('Expected defines array: ' + output); - } - - return info; -} - - /** * Given the path to a source file, get the list of provides. * @param {string} srcPath Path to source file. @@ -268,7 +268,7 @@ function main(callback) { if (require.main === module) { main(function(err) { if (err) { - console.error(err.message); + process.stderr.write(err.message + '\n'); process.exit(1); } else { process.exit(0); diff --git a/tasks/parse-examples.js b/tasks/parse-examples.js index 0def06131a..09e86c1b64 100644 --- a/tasks/parse-examples.js +++ b/tasks/parse-examples.js @@ -144,7 +144,7 @@ async.waterfall([ writeExampleList ], function(err) { if (err) { - console.error(err); + process.stderr.write(err + '\n'); process.exit(1); } }); diff --git a/tasks/test.js b/tasks/test.js index 40ee8ae198..1028659ef1 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -42,13 +42,13 @@ function listen(min, max, server, callback) { */ serve.createServer(function(err, server) { if (err) { - console.error(err.message); + process.stderr.write(err.message + '\n'); process.exit(1); } listen(3001, 3005, server, function(err) { if (err) { - console.error('Server failed to start: ' + err.message); + process.stderr.write('Server failed to start: ' + err.message + '\n'); process.exit(1); }