awc-zns-mtd 2.6.1 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -44,29 +44,39 @@ async function createConfigFile(awcDir, config) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Carga configuración desde archivo YAML
|
|
47
|
+
* Carga configuración desde archivo JSON o YAML
|
|
48
48
|
*/
|
|
49
49
|
async function loadConfig(awcDir) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
50
|
+
// Intentar primero JSON (usado por awc new)
|
|
51
|
+
const configJsonPath = path.join(awcDir, 'config.json');
|
|
52
|
+
if (await fs.pathExists(configJsonPath)) {
|
|
53
|
+
try {
|
|
54
|
+
return await fs.readJson(configJsonPath);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Error al cargar config.json:', error.message);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
// Fallback a YAML (compatibilidad)
|
|
61
|
+
const configYamlPath = path.join(awcDir, 'config.yaml');
|
|
62
|
+
if (await fs.pathExists(configYamlPath)) {
|
|
63
|
+
try {
|
|
64
|
+
const content = await fs.readFile(configYamlPath, 'utf8');
|
|
65
|
+
return yaml.load(content);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error('Error al cargar config.yaml:', error.message);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
70
|
+
|
|
71
|
+
return null;
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
/**
|
|
66
|
-
* Actualiza configuración existente
|
|
75
|
+
* Actualiza configuración existente (JSON)
|
|
67
76
|
*/
|
|
68
77
|
async function updateConfig(awcDir, newConfig) {
|
|
69
|
-
|
|
78
|
+
const configPath = path.join(awcDir, 'config.json');
|
|
79
|
+
await fs.writeJson(configPath, newConfig, { spaces: 2 });
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
/**
|