-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also await the actual build function, so ember-cli-build.js can export an async builder function. Co-authored-by: Robert Jackson <rjackson@linkedin.com>
- Loading branch information
Showing
11 changed files
with
269 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
'use strict'; | ||
const findUp = require('find-up'); | ||
const path = require('path'); | ||
const url = require('url'); | ||
|
||
// TODO: make rob happy with async import | ||
module.exports = function (dir) { | ||
let buildFilePath = findUp.sync('ember-cli-build.js', { cwd: dir }); | ||
module.exports = async function (dir) { | ||
let buildFilePath = null; | ||
|
||
if (!buildFilePath) { | ||
buildFilePath = findUp.sync('ember-cli-build.cjs', { cwd: dir }); | ||
for (let ext of ['js', 'mjs', 'cjs']) { | ||
let candidate = findUp.sync(`ember-cli-build.${ext}`, { cwd: dir }); | ||
if (candidate) { | ||
buildFilePath = candidate; | ||
break; | ||
} | ||
} | ||
|
||
// Note: In the future this should throw | ||
if (!buildFilePath) { | ||
if (buildFilePath === null) { | ||
return null; | ||
} | ||
|
||
process.chdir(path.dirname(buildFilePath)); | ||
|
||
let buildFile = null; | ||
let buildFileUrl = url.pathToFileURL(buildFilePath); | ||
try { | ||
buildFile = require(buildFilePath); | ||
// eslint-disable-next-line node/no-unsupported-features/es-syntax | ||
let fn = (await import(buildFileUrl)).default; | ||
return fn; | ||
} catch (err) { | ||
err.message = `Could not require 'ember-cli-build.js': ${err.message}`; | ||
err.message = `Could not \`import('${buildFileUrl}')\`: ${err.message}`; | ||
throw err; | ||
} | ||
|
||
return buildFile; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.