Skip to content

Commit 12ee1ef

Browse files
committed
chore: monkey patch findBuildFile to use our angular-cli-build file.
1 parent 7bc20ff commit 12ee1ef

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/cli/index.js

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
/*eslint-disable no-console */
2-
const cli = require('ember-cli/lib/cli');
3-
const path = require('path');
42

53
// This file hooks up on require calls to transpile TypeScript.
64
const fs = require('fs');
@@ -37,6 +35,38 @@ require.extensions['.ts'] = function(m, filename) {
3735
};
3836

3937

38+
/**
39+
* Monkey patch `ember-cli/lib/utilities/find-build-file` to find our build
40+
* file when looking for `ember-cli-build.js`. This needs to be the first
41+
* thing that happens before we `require()` any ember files.
42+
*
43+
* TODO: Remove this hack and replace it with some configuration when/if we
44+
* move away from ember. Or when ember allows us to configure this in
45+
* an addon.
46+
*/
47+
const findBuildFileRequirePath = 'ember-cli/lib/utilities/find-build-file';
48+
const originalFindBuildFile = require(findBuildFileRequirePath);
49+
50+
const mod = require.cache[require.resolve(findBuildFileRequirePath)];
51+
mod.exports = function patchedFindBuildFile(name) {
52+
if (name == 'ember-cli-build.js') {
53+
const result = originalFindBuildFile.call(this, 'angular-cli-build.js');
54+
55+
// Fallback to ember-cli-build if angular-cli-build isn't found.
56+
if (result) {
57+
return result;
58+
}
59+
}
60+
61+
return originalFindBuildFile.apply(this, arguments);
62+
};
63+
64+
65+
66+
const cli = require('ember-cli/lib/cli');
67+
const path = require('path');
68+
69+
4070
module.exports = function(options) {
4171
const oldStdoutWrite = process.stdout.write;
4272
process.stdout.write = function (line) {

0 commit comments

Comments
 (0)