Skip to content

Commit

Permalink
Refactor transform.js into a ScriptTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Apr 27, 2017
1 parent 2cb4f23 commit bea6547
Show file tree
Hide file tree
Showing 8 changed files with 462 additions and 485 deletions.
8 changes: 6 additions & 2 deletions packages/jest-cli/src/generateEmptyCoverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {ProjectConfig, Path} from 'types/Config';

const IstanbulInstrument = require('istanbul-lib-instrument');

const {transformSource, shouldInstrument} = require('jest-runtime');
const {ScriptTransformer, shouldInstrument} = require('jest-runtime');

module.exports = function(
source: string,
Expand All @@ -24,7 +24,11 @@ module.exports = function(
if (shouldInstrument(filename, config)) {
// Transform file without instrumentation first, to make sure produced
// source code is ES6 (no flowtypes etc.) and can be instrumented
const transformResult = transformSource(filename, config, source, false);
const transformResult = new ScriptTransformer(config).transformSource(
filename,
source,
false,
);
const instrumenter = IstanbulInstrument.createInstrumenter();
instrumenter.instrumentSync(transformResult.code, filename);
return {
Expand Down
Loading

0 comments on commit bea6547

Please sign in to comment.