Use rewire to import non-module files, and use nyc for test coverage.

This commit is contained in:
Viktor Kovacs 2021-03-30 18:34:00 +02:00
parent 1c3b795ae8
commit 6bc1b33e8a
3 changed files with 6 additions and 17 deletions

View File

@ -8,10 +8,13 @@
"google-closure-compiler": "^20210302.0.0",
"jshint": "^2.12.0",
"mocha": "^8.3.2",
"svgo": "^2.2.2"
"rewire": "^5.0.0",
"svgo": "^2.2.2",
"nyc": "^15.1.0"
},
"scripts": {
"test": "mocha test",
"coverage": "nyc mocha test",
"build": "python tools/create_package.py",
"update": "python tools/update_includes.py",
"svg": "python tools/optimize_svg_files.py"

View File

@ -1,14 +0,0 @@
module.exports =
{
AddNativeSourceFile : function (fileName)
{
var path = require ('path');
var rootDir = path.join (__dirname, '..');
var fullPath = path.resolve (rootDir, fileName);
var fs = require ('fs');
var content = fs.readFileSync (fullPath).toString ();
eval.apply (global, [content]);
}
}

View File

@ -1,10 +1,10 @@
var path = require ('path');
var nativeImport = require ('../framework/native_import.js');
var rewire = require ('rewire');
var config = require ('../../tools/config.json')
var importerFiles = config['importer_files'];
var fileIndex, filePath;
for (fileIndex = 0; fileIndex < importerFiles.length; fileIndex++) {
filePath = importerFiles[fileIndex];
nativeImport.AddNativeSourceFile (path.join ('..', filePath));
rewire (path.join ('..', '..', filePath));
}