Skip to content

Commit f58fd37

Browse files
committed
feat: add feature for customizing
1 parent bebc8e5 commit f58fd37

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

babel-plugin-code-push/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ const OPTIONS_TO_BUNDLE = [
99
"updateChecker",
1010
];
1111

12-
module.exports = function (babel) {
12+
module.exports = function (babel, options) {
1313
const { types: t } = babel;
14+
const configPath =
15+
options.configPath ?? path.resolve(process.cwd(), "codepush.config.js");
1416

1517
// Load config and imports from `codepush.config.js`
16-
const { config, configImports, importedIdentifiers } = loadConfig();
18+
const { config, configImports, importedIdentifiers } = loadConfig(configPath);
1719

1820
// Helper to serialize config values to AST nodes
1921
function serializeConfigToNode(value) {
@@ -58,8 +60,7 @@ module.exports = function (babel) {
5860
throw new Error(`Unsupported config value type: ${typeof value}`);
5961
}
6062

61-
function loadConfig() {
62-
const configPath = path.resolve(process.cwd(), "codepush.config.js");
63+
function loadConfig(configPath) {
6364
if (!fs.existsSync(configPath)) {
6465
throw new Error(
6566
"codepush.config.js not found. Please ensure it exists in the root directory."

0 commit comments

Comments
 (0)