react-native/jestSupport/scriptPreprocess.js

26 lines
584 B
JavaScript
Raw Normal View History

2015-01-30 01:10:49 +00:00
'use strict';
var transformer = require('../packager/transformer.js');
2015-01-30 01:10:49 +00:00
function transformSource(src, filename) {
return transformer.transform(src, filename).code;
2015-01-30 01:10:49 +00:00
}
module.exports = {
transformSource: transformSource,
process: function(src, fileName) {
if (fileName.match(/node_modules/)) {
return src;
}
2015-01-30 01:10:49 +00:00
try {
return transformSource(src, fileName);
2015-01-30 01:10:49 +00:00
} catch(e) {
throw new Error('\nError transforming file:\n js/' +
(fileName.split('/js/')[1] || fileName) + ':' + e.lineNumber + ': \'' +
e.message + '\'\n');
}
}
};