|
1 | 1 | /**
|
2 |
| - * This class is the base interface for compilers that are used by |
3 |
| - * electron-compile. If your compiler library only supports a |
| 2 | + * This class is the base interface for compilers that are used by |
| 3 | + * electron-compile. If your compiler library only supports a |
4 | 4 | * synchronous API, use SimpleCompilerBase instead.
|
5 | 5 | *
|
6 | 6 | * @interface
|
7 |
| - */ |
| 7 | + */ |
8 | 8 | export class CompilerBase {
|
9 | 9 | constructor() {
|
10 | 10 | this.compilerOptions = {};
|
11 | 11 | }
|
12 |
| - |
13 |
| - /** |
14 |
| - * This method describes the MIME types that your compiler supports as input. |
| 12 | + |
| 13 | + /** |
| 14 | + * This method describes the MIME types that your compiler supports as input. |
15 | 15 | * Many precompiled file types don't have a specific MIME type, so if it's not
|
16 | 16 | * recognized by the mime-types package, you need to patch rig-mime-types in
|
17 | 17 | * electron-compile.
|
18 | 18 | *
|
19 | 19 | * @return {string[]} An array of MIME types that this compiler can compile.
|
20 | 20 | *
|
21 | 21 | * @abstract
|
22 |
| - */ |
| 22 | + */ |
23 | 23 | static getInputMimeTypes() {
|
24 | 24 | throw new Error("Implement me!");
|
25 | 25 | }
|
26 | 26 |
|
27 | 27 |
|
28 | 28 | /**
|
29 | 29 | * Determines whether a file should be compiled
|
30 |
| - * |
| 30 | + * |
31 | 31 | * @param {string} fileName The full path of a file to compile.
|
32 | 32 | * @param {object} compilerContext An object that compilers can add extra
|
33 | 33 | information to as part of a job - the caller
|
34 | 34 | won't do anything with this.
|
35 | 35 | * @return {Promise<bool>} True if you are able to compile this file.
|
36 | 36 | *
|
37 | 37 | * @abstract
|
38 |
| - */ |
39 |
| - async shouldCompileFile(fileName, compilerContext) { |
| 38 | + */ |
| 39 | + async shouldCompileFile(fileName, compilerContext) { // eslint-disable-line no-unused-vars |
40 | 40 | throw new Error("Implement me!");
|
41 | 41 | }
|
42 | 42 |
|
43 |
| - |
44 |
| - /** |
| 43 | + |
| 44 | + /** |
45 | 45 | * Returns the dependent files of this file. This is used for languages such
|
46 | 46 | * as LESS which allow you to import / reference other related files. In future
|
47 | 47 | * versions of electron-compile, we will use this information to invalidate
|
48 | 48 | * all of the parent files if a child file changes.
|
49 |
| - * |
| 49 | + * |
50 | 50 | * @param {string} sourceCode The contents of filePath
|
51 | 51 | * @param {string} fileName The full path of a file to compile.
|
52 | 52 | * @param {object} compilerContext An object that compilers can add extra
|
53 | 53 | information to as part of a job - the caller
|
54 | 54 | won't do anything with this.
|
55 | 55 | * @return {Promise<string[]>} An array of dependent file paths, or an empty
|
56 |
| - * array if there are no dependent files. |
| 56 | + * array if there are no dependent files. |
57 | 57 | *
|
58 | 58 | * @abstract
|
59 |
| - */ |
60 |
| - async determineDependentFiles(sourceCode, fileName, compilerContext) { |
| 59 | + */ |
| 60 | + async determineDependentFiles(sourceCode, fileName, compilerContext) { // eslint-disable-line no-unused-vars |
61 | 61 | throw new Error("Implement me!");
|
62 | 62 | }
|
63 | 63 |
|
64 |
| - |
65 |
| - /** |
| 64 | + |
| 65 | + /** |
66 | 66 | * Compiles the file
|
67 |
| - * |
| 67 | + * |
68 | 68 | * @param {string} sourceCode The contents of filePath
|
69 | 69 | * @param {string} fileName The full path of a file to compile.
|
70 | 70 | * @param {object} compilerContext An object that compilers can add extra
|
71 | 71 | information to as part of a job - the caller
|
72 | 72 | won't do anything with this.
|
73 | 73 | * @return {Promise<object>} An object representing the compiled result
|
74 | 74 | * @property {string} code The compiled code
|
75 |
| - * @property {string} mimeType The MIME type of the compiled result, which |
| 75 | + * @property {string} mimeType The MIME type of the compiled result, which |
76 | 76 | * should exist in the mime-types database.
|
77 | 77 | *
|
78 | 78 | * @abstract
|
79 |
| - */ |
80 |
| - async compile(sourceCode, fileName, compilerContext) { |
| 79 | + */ |
| 80 | + async compile(sourceCode, fileName, compilerContext) { // eslint-disable-line no-unused-vars |
81 | 81 | throw new Error("Implement me!");
|
82 | 82 | }
|
83 | 83 |
|
84 |
| - shouldCompileFileSync(fileName, compilerContext) { |
| 84 | + shouldCompileFileSync(fileName, compilerContext) { // eslint-disable-line no-unused-vars |
85 | 85 | throw new Error("Implement me!");
|
86 | 86 | }
|
87 | 87 |
|
88 |
| - determineDependentFilesSync(sourceCode, fileName, compilerContext) { |
| 88 | + determineDependentFilesSync(sourceCode, fileName, compilerContext) { // eslint-disable-line no-unused-vars |
89 | 89 | throw new Error("Implement me!");
|
90 | 90 | }
|
91 | 91 |
|
92 |
| - compileSync(sourceCode, fileName, compilerContext) { |
| 92 | + compileSync(sourceCode, fileName, compilerContext) { // eslint-disable-line no-unused-vars |
93 | 93 | throw new Error("Implement me!");
|
94 | 94 | }
|
95 | 95 |
|
96 | 96 | /**
|
97 |
| - * Returns a version number representing the version of the underlying |
| 97 | + * Returns a version number representing the version of the underlying |
98 | 98 | * compiler library. When this number changes, electron-compile knows
|
99 | 99 | * to throw all away its generated code.
|
100 |
| - * |
101 |
| - * @return {string} A version number. Note that this string isn't |
| 100 | + * |
| 101 | + * @return {string} A version number. Note that this string isn't |
102 | 102 | * parsed in any way, just compared to the previous
|
103 | 103 | * one for equality.
|
104 | 104 | *
|
105 | 105 | * @abstract
|
106 |
| - */ |
| 106 | + */ |
107 | 107 | getCompilerVersion() {
|
108 | 108 | throw new Error("Implement me!");
|
109 | 109 | }
|
110 | 110 | }
|
111 | 111 |
|
112 | 112 |
|
113 | 113 | /**
|
114 |
| - * This class implements all of the async methods of CompilerBase by just |
115 |
| - * calling the sync version. Use it to save some time when implementing |
| 114 | + * This class implements all of the async methods of CompilerBase by just |
| 115 | + * calling the sync version. Use it to save some time when implementing |
116 | 116 | * simple compilers.
|
117 | 117 | *
|
118 |
| - * To use it, implement the compile method, the getCompilerVersion method, |
119 |
| - * and the getInputMimeTypes static method. |
120 |
| - * |
| 118 | + * To use it, implement the compile method, the getCompilerVersion method, |
| 119 | + * and the getInputMimeTypes static method. |
| 120 | + * |
121 | 121 | * @abstract
|
122 |
| - */ |
| 122 | + */ |
123 | 123 | export class SimpleCompilerBase extends CompilerBase {
|
124 | 124 | constructor() {
|
125 | 125 | super();
|
126 | 126 | }
|
127 | 127 |
|
128 |
| - async shouldCompileFile(fileName, compilerContext) { |
| 128 | + async shouldCompileFile(fileName, compilerContext) { // eslint-disable-line no-unused-vars |
129 | 129 | return true;
|
130 | 130 | }
|
131 | 131 |
|
132 |
| - async determineDependentFiles(sourceCode, filePath, compilerContext) { |
| 132 | + async determineDependentFiles(sourceCode, filePath, compilerContext) { // eslint-disable-line no-unused-vars |
133 | 133 | return [];
|
134 | 134 | }
|
135 | 135 |
|
136 | 136 | async compile(sourceCode, filePath, compilerContext) {
|
137 | 137 | return this.compileSync(sourceCode, filePath, compilerContext);
|
138 | 138 | }
|
139 | 139 |
|
140 |
| - shouldCompileFileSync(fileName, compilerContext) { |
| 140 | + shouldCompileFileSync(fileName, compilerContext) { // eslint-disable-line no-unused-vars |
141 | 141 | return true;
|
142 | 142 | }
|
143 | 143 |
|
144 |
| - determineDependentFilesSync(sourceCode, filePath, compilerContext) { |
| 144 | + determineDependentFilesSync(sourceCode, filePath, compilerContext) { // eslint-disable-line no-unused-vars |
145 | 145 | return [];
|
146 | 146 | }
|
147 | 147 | }
|
0 commit comments