52 lines
5.8 KiB
JavaScript
52 lines
5.8 KiB
JavaScript
|
"use strict";
|
||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
const lodash_1 = require("lodash");
|
||
|
const test_page_url_1 = require("../../api/test-page-url");
|
||
|
const type_assertions_1 = require("../../errors/runtime/type-assertions");
|
||
|
class TestFileCompilerBase {
|
||
|
constructor({ baseUrl }) {
|
||
|
const escapedExt = (0, lodash_1.flatten)([this.getSupportedExtension()])
|
||
|
.map(ext => (0, lodash_1.escapeRegExp)(ext))
|
||
|
.join('|');
|
||
|
this.supportedExtensionRe = new RegExp(`(${escapedExt})$`);
|
||
|
this._ensureBaseUrl(baseUrl);
|
||
|
}
|
||
|
_ensureBaseUrl(url) {
|
||
|
if (!url)
|
||
|
return;
|
||
|
this.baseUrl = url;
|
||
|
(0, type_assertions_1.assertType)(type_assertions_1.is.string, '_ensureBaseUrl', 'The base URL', this.baseUrl);
|
||
|
(0, test_page_url_1.assertBaseUrl)(this.baseUrl, '_ensureBaseUrl');
|
||
|
this.baseUrl = (0, test_page_url_1.getUrl)(this.baseUrl);
|
||
|
}
|
||
|
_hasTests( /* code */) {
|
||
|
throw new Error('Not implemented');
|
||
|
}
|
||
|
getSupportedExtension() {
|
||
|
throw new Error('Not implemented');
|
||
|
}
|
||
|
async precompile( /* testFilesInfo */) {
|
||
|
throw new Error('Not implemented');
|
||
|
}
|
||
|
async compile( /* code, filename */) {
|
||
|
throw new Error('Not implemented');
|
||
|
}
|
||
|
async execute( /* compiledCode, filename */) {
|
||
|
throw new Error('Not implemented');
|
||
|
}
|
||
|
canCompile(code, filename) {
|
||
|
return this.supportedExtensionRe.test(filename);
|
||
|
}
|
||
|
get canCompileInEsm() {
|
||
|
return false;
|
||
|
}
|
||
|
get canPrecompile() {
|
||
|
return false;
|
||
|
}
|
||
|
cleanUp() {
|
||
|
// NOTE: Optional. Do nothing by default.
|
||
|
}
|
||
|
}
|
||
|
exports.default = TestFileCompilerBase;
|
||
|
module.exports = exports.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