vsoFormatter.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright 2016 Palantir Technologies, Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. var tslib_1 = require("tslib");
  20. var abstractFormatter_1 = require("../language/formatter/abstractFormatter");
  21. var Utils = require("../utils");
  22. var Formatter = /** @class */ (function (_super) {
  23. tslib_1.__extends(Formatter, _super);
  24. function Formatter() {
  25. return _super !== null && _super.apply(this, arguments) || this;
  26. }
  27. /* tslint:enable:object-literal-sort-keys */
  28. Formatter.prototype.format = function (failures) {
  29. var outputLines = failures.map(function (failure) {
  30. var fileName = failure.getFileName();
  31. var failureString = failure.getFailure();
  32. var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
  33. var line = lineAndCharacter.line + 1;
  34. var character = lineAndCharacter.character + 1;
  35. var code = failure.getRuleName();
  36. var properties = "sourcepath=" + fileName + ";linenumber=" + line + ";columnnumber=" + character + ";code=" + code + ";";
  37. return "##vso[task.logissue type=warning;" + properties + "]" + failureString;
  38. });
  39. return outputLines.join("\n") + "\n";
  40. };
  41. /* tslint:disable:object-literal-sort-keys */
  42. Formatter.metadata = {
  43. formatterName: "vso",
  44. description: "Formats output as VSO/TFS logging commands.",
  45. descriptionDetails: Utils.dedent(templateObject_1 || (templateObject_1 = tslib_1.__makeTemplateObject(["\n Integrates with Visual Studio Online and Team Foundation Server by outputting errors\n as 'warning' logging commands."], ["\n Integrates with Visual Studio Online and Team Foundation Server by outputting errors\n as 'warning' logging commands."]))),
  46. sample: "##vso[task.logissue type=warning;sourcepath=myFile.ts;linenumber=1;columnnumber=14;code=semicolon;]Missing semicolon",
  47. consumer: "machine",
  48. };
  49. return Formatter;
  50. }(abstractFormatter_1.AbstractFormatter));
  51. exports.Formatter = Formatter;
  52. var templateObject_1;