-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
10,106 additions
and
13,740 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
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,10 +1,47 @@ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const { getArgs } = require("./args"); | ||
const { log } = require("./logger"); | ||
const { isString } = require("./utils"); | ||
|
||
const projectRoot = fs.realpathSync(process.cwd()); | ||
const packageJsonPath = path.join(projectRoot, "package.json"); | ||
|
||
log("Project root path resolved to: ", projectRoot); | ||
|
||
let configFilePath = ""; | ||
|
||
const configFilenames = ["craco.config.js", ".cracorc.js", ".cracorc"]; | ||
|
||
const args = getArgs(); | ||
|
||
if (args.config.isProvided) { | ||
configFilePath = path.resolve(projectRoot, args.config.value); | ||
} else { | ||
const package = require(packageJsonPath); | ||
|
||
if (package.cracoConfig) { | ||
if (!isString(package.cracoConfig)) { | ||
throw new Error("craco: 'cracoConfig' value must be a string."); | ||
} | ||
|
||
configFilePath = path.resolve(projectRoot, package.cracoConfig); | ||
} else { | ||
for (const filename of configFilenames) { | ||
const filePath = path.join(projectRoot, filename); | ||
|
||
if (fs.existsSync(filePath)) { | ||
configFilePath = filePath; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
log("Config file path resolved to: ", configFilePath); | ||
|
||
module.exports = { | ||
projectRoot | ||
projectRoot, | ||
packageJsonPath, | ||
configFilePath | ||
}; |
Oops, something went wrong.