Skip to content

Commit

Permalink
Always create config field classes regardless of the data value (#28)
Browse files Browse the repository at this point in the history
Also cleanup some code.
  • Loading branch information
lingyuncai authored Oct 24, 2023
1 parent c85a3c9 commit 3b7fcce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ class ExportedFuncsConfig extends BaseBuildConfig {
}

updateToEnvs(): EnvUpdateSet {
console.log(`updateToEnvs from exportedFuncs`);
const ldflagsToUpdate: IArg[] = [];
const val = this.value as string;
if (val && val.trim()) {
console.log(`if - ${val}`);
const uniqFns = [
...new Set(
val
Expand All @@ -77,7 +75,6 @@ class ExportedFuncsConfig extends BaseBuildConfig {
type: "replace",
});
} else {
console.log(`else - ${val}`);
// if exportedFuncs is "", remove -sEXPORTED_FUNCTIONS arg
ldflagsToUpdate.push({
option: "-sEXPORTED_FUNCTIONS",
Expand Down
25 changes: 12 additions & 13 deletions src/project_caches/project_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,9 @@ class ProjectBuildConfig implements IProjectBuildConfig {
const createConfigClass = (configType: BuildConfigType) => {
configClassMap[configType] = new (configFromType(configType))(configType, this._data);
};
const jsonKeys = Object.keys(this._data);
if (jsonKeys.includes("exportedFuncs")) {
createConfigClass("exportedFuncs");
}
if (jsonKeys.includes("exportedRuntimeMethods")) {
createConfigClass("exportedRuntimeMethods");
}
if (jsonKeys.includes("preloadFiles")) {
createConfigClass("preloadFiles");
}
createConfigClass("exportedFuncs");
createConfigClass("exportedRuntimeMethods");
createConfigClass("preloadFiles");
this._configFields = configClassMap;
}
return this._configFields;
Expand Down Expand Up @@ -297,7 +290,9 @@ class ProjectBuildConfig implements IProjectBuildConfig {
const envUpdateSet = configClass.updateToEnvs();
this.save();
(Object.keys(envUpdateSet) as EnvType[]).forEach((env) => {
this.updateEnv(env, envUpdateSet[env]);
if (envUpdateSet[env].length) {
this.updateEnv(env, envUpdateSet[env]);
}
});
}
}
Expand All @@ -319,7 +314,9 @@ class ProjectBuildConfig implements IProjectBuildConfig {
if (optClass.updateToEnvs) {
const envUpdateSet = optClass.updateToEnvs();
(Object.keys(envUpdateSet) as EnvType[]).forEach((env) => {
this.updateEnv(env, envUpdateSet[env]);
if (envUpdateSet[env].length) {
this.updateEnv(env, envUpdateSet[env]);
}
});
}
}
Expand Down Expand Up @@ -363,7 +360,9 @@ class ProjectBuildConfig implements IProjectBuildConfig {
const envUpdateSet = optClass.updateFromEnvs(currentEnv, envFlags);
this.save();
(Object.keys(envUpdateSet) as EnvType[]).forEach((env) => {
this.updateEnv(env, envUpdateSet[env]);
if (envUpdateSet[env].length) {
this.updateEnv(env, envUpdateSet[env]);
}
});
}
});
Expand Down

0 comments on commit 3b7fcce

Please sign in to comment.