Skip to content

Commit

Permalink
fix(windows): fire analyzeJsFile hook for Windows
Browse files Browse the repository at this point in the history
Fixes TIMOB-27452
  • Loading branch information
ewanharris authored and sgtcoolguy committed Nov 14, 2019
1 parent 58d7336 commit e6340c2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion cli/lib/tasks/process-js-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class ProcessJsTask extends IncrementalFileTask {
this.defaultAnalyzeOptions = options.defaultAnalyzeOptions;

this.dataFilePath = path.join(this.incrementalDirectory, 'data.json');

this.fileContentsMap = new Map();

this.resetTaskData();

this.createHooks();
Expand Down Expand Up @@ -166,6 +169,18 @@ class ProcessJsTask extends IncrementalFileTask {
});
});

// Windows hyperloop requires that a build.windows.analyzeJsFile runs before compileJsFile
// so patch the compileJsFile hook to run that hook first and then fire the compileJsFile
// TODO: remove this in 9.0.0 TIMOB-27601
if (this.platform === 'windows') {
let origCompileJsHook = compileJsFileHook;

compileJsFileHook = this.builder.cli.createHook(`build.${this.platform}.analyzeJsFile`, this.builder, (from, to, cb) => {
const r = this.fileContentsMap.get(from);
origCompileJsHook(r, from, to, cb);
});
}

this.copyResourceHook = promisify(this.builder.cli.createHook(`build.${this.platform}.copyResource`, this.builder, (from, to, done) => {
const originalContents = fs.readFileSync(from).toString();

Expand All @@ -174,8 +189,15 @@ class ProcessJsTask extends IncrementalFileTask {
contents: originalContents,
symbols: []
};
if (this.platform === 'windows') {
// We can't pass the contents through the analyzeJsFile hook so store them in a map
// which we can then pull the contents from
this.fileContentsMap.set(from, r);
compileJsFileHook(from, to, done);
} else {
compileJsFileHook(r, from, to, done);

compileJsFileHook(r, from, to, done);
}
}));
}

Expand Down

0 comments on commit e6340c2

Please sign in to comment.