.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / vfile / index.js
1 'use strict';
2
3 var VMessage = require('vfile-message');
4 var VFile = require('./core.js');
5
6 module.exports = VFile;
7
8 var proto = VFile.prototype;
9
10 proto.message = message;
11 proto.info = info;
12 proto.fail = fail;
13
14 /* Slight backwards compatibility.  Remove in the future. */
15 proto.warn = message;
16
17 /* Create a message with `reason` at `position`.
18  * When an error is passed in as `reason`, copies the stack. */
19 function message(reason, position, origin) {
20   var filePath = this.path;
21   var message = new VMessage(reason, position, origin);
22
23   if (filePath) {
24     message.name = filePath + ':' + message.name;
25     message.file = filePath;
26   }
27
28   message.fatal = false;
29
30   this.messages.push(message);
31
32   return message;
33 }
34
35 /* Fail. Creates a vmessage, associates it with the file,
36  * and throws it. */
37 function fail() {
38   var message = this.message.apply(this, arguments);
39
40   message.fatal = true;
41
42   throw message;
43 }
44
45 /* Info. Creates a vmessage, associates it with the file,
46  * and marks the fatality as null. */
47 function info() {
48   var message = this.message.apply(this, arguments);
49
50   message.fatal = null;
51
52   return message;
53 }