forked from madskristensen/WebEssentials2013
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Nodejs as a Web Service - pt. 6. (madskristensen#381)
* Server: Adds services: CoffeeLint, JSCS, JsHint and TSLint. * Server: Fixes error messages. * Server: Uses Regex for error parsing. * Server: Removes debug messages. * Server: Robust port discovery method. * Server: Removed Dispose(). * Client: Adds AsyncLock to NodeServer. * PreBuild: Adds XRegExp package for named capturing groups.
- Loading branch information
Showing
17 changed files
with
466 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
EditorExtensions/Resources/server/services/srv-coffeelint.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
//#region Imports | ||
var coffeelint = require("coffeelint"), | ||
configFinder = require("coffeelint/lib/configfinder"), | ||
fs = require("fs"); | ||
//#endregion | ||
|
||
//#region Reporter | ||
var reporter = function (results, writer, path) { | ||
var errorItems = results.map(function (error) { | ||
return { | ||
Line: error.lineNumber, | ||
Message: "CoffeeLint: " + error.message, | ||
FileName: path | ||
}; | ||
}); | ||
|
||
writer.write(JSON.stringify({ | ||
Success: true, | ||
Remarks: "Successful!", | ||
Output: { | ||
Content: errorItems | ||
} | ||
})); | ||
writer.end(); | ||
} | ||
//#endregion | ||
|
||
//#region Handler | ||
var handleCoffeeLint = function (writer, params) { | ||
var tempError = console.error; | ||
console.error = function () { /* waste log messages toDevNull */ }; | ||
|
||
var config = configFinder.getConfig(params.sourceFileName); | ||
|
||
console.error = tempError; | ||
|
||
if (config == null) { | ||
writer.write(JSON.stringify({ Success: false, Remarks: "CoffeeLint: Invalid Config file" })); | ||
writer.end(); | ||
return; | ||
} | ||
|
||
fs.readFile(params.sourceFileName, 'utf8', function (err, data) { | ||
if (err) { | ||
writer.write(JSON.stringify({ Success: false, Remarks: "CoffeeLint: Error reading input file.", Details: err })); | ||
writer.end(); | ||
return; | ||
} | ||
|
||
var results = coffeelint.lint(data, config); | ||
reporter(results, writer, params.sourceFileName); | ||
}); | ||
}; | ||
//#endregion | ||
|
||
//#region Exports | ||
module.exports = handleCoffeeLint; | ||
//#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.