@barcidev/ngx-autogen 0.1.46 → 0.1.48

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barcidev/ngx-autogen",
3
- "version": "0.1.46",
3
+ "version": "0.1.48",
4
4
  "description": "A collection of Angular schematics for essential functionalities.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -138,15 +138,18 @@ function registerProviderInComponent(options, componentFile) {
138
138
  function resolveComponentContext(tree, options) {
139
139
  const fullPath = process.cwd();
140
140
  const srcIndex = fullPath.lastIndexOf("src");
141
- const path = (0, path_1.normalize)(srcIndex !== -1
142
- ? fullPath.substring(srcIndex)
143
- : (0, path_1.join)((0, path_1.normalize)("src"), "app"));
141
+ const path = options.path ||
142
+ (0, path_1.normalize)(srcIndex !== -1
143
+ ? fullPath.substring(srcIndex)
144
+ : (0, path_1.join)((0, path_1.normalize)("src"), "app"));
145
+ let componentName = options.name;
144
146
  const directory = tree.getDir(path);
145
147
  const componentFile = directory.subfiles.find((f) => f.endsWith(".component.ts")) ||
146
148
  directory.subfiles.find((f) => f.endsWith(".ts"));
147
- const componentName = componentFile
148
- ? componentFile.replace(".component.ts", "").replace(".ts", "")
149
- : options.name;
149
+ if (!options.name) {
150
+ componentName =
151
+ (componentFile === null || componentFile === void 0 ? void 0 : componentFile.replace(".component.ts", "").replace(".ts", "")) || "file";
152
+ }
150
153
  if (!componentName)
151
154
  throw new schematics_1.SchematicsException("❌ No se pudo determinar el nombre del componente.");
152
155
  return { path, componentFile, componentName };