aberlaas-helper 2.40.0 → 2.41.1

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/lib/helper.js CHANGED
@@ -117,16 +117,16 @@ export const __ = {
117
117
  },
118
118
 
119
119
  /**
120
- * Return a config object for a specific tool.
120
+ * Return the absolute path of the config file for a specific tool.
121
121
  * Will first check for the user supplied path to the config file, then
122
122
  * fallback to the default config file in the host, and finally fallback to
123
- * the default base config in the aberlaas module.
123
+ * the path of the base config file in the aberlaas module.
124
124
  * @param {string} userConfigPath User specified config file, relative to the host root
125
125
  * @param {string} hostConfigPath Default host config path, relative to the host root
126
- * @param {object} baseConfig Base aberlaas config, final fallback
127
- * @returns {object} Config object
126
+ * @param {string} baseConfigPath Absolute path to the base aberlaas config file, final fallback
127
+ * @returns {string|null} Absolute path of the config file, or null if none found
128
128
  */
129
- async getConfig(userConfigPath, hostConfigPath, baseConfig = {}) {
129
+ async getConfigPath(userConfigPath, hostConfigPath, baseConfigPath = null) {
130
130
  // Taking value from --config in CLI in priority
131
131
  if (userConfigPath) {
132
132
  const configPath = __.hostGitPath(userConfigPath);
@@ -137,17 +137,37 @@ export const __ = {
137
137
  );
138
138
  }
139
139
 
140
- return await firostImport(configPath, { forceReload: true });
140
+ return configPath;
141
141
  }
142
142
 
143
143
  // Checking for custom config in the host
144
144
  if (hostConfigPath) {
145
145
  const hostConfigFullPath = __.hostGitPath(hostConfigPath);
146
146
  if (await exists(hostConfigFullPath)) {
147
- return await firostImport(hostConfigFullPath, { forceReload: true });
147
+ return hostConfigFullPath;
148
148
  }
149
149
  }
150
150
 
151
+ // Fallback on default config file in aberlaas
152
+ return baseConfigPath;
153
+ },
154
+
155
+ /**
156
+ * Return a config object for a specific tool.
157
+ * Will first check for the user supplied path to the config file, then
158
+ * fallback to the default config file in the host, and finally fallback to
159
+ * the default base config in the aberlaas module.
160
+ * @param {string} userConfigPath User specified config file, relative to the host root
161
+ * @param {string} hostConfigPath Default host config path, relative to the host root
162
+ * @param {object} baseConfig Base aberlaas config, final fallback
163
+ * @returns {object} Config object
164
+ */
165
+ async getConfig(userConfigPath, hostConfigPath, baseConfig = {}) {
166
+ const configPath = await __.getConfigPath(userConfigPath, hostConfigPath);
167
+ if (configPath) {
168
+ return await firostImport(configPath, { forceReload: true });
169
+ }
170
+
151
171
  // Fallback on default config in aberlaas
152
172
  return baseConfig;
153
173
  },
@@ -195,5 +215,6 @@ export const findHostFiles = wrap(__, 'findHostFiles');
195
215
  export const hostGitRoot = wrap(__, 'hostGitRoot');
196
216
  export const hostGitPath = wrap(__, 'hostGitPath');
197
217
  export const getConfig = wrap(__, 'getConfig');
218
+ export const getConfigPath = wrap(__, 'getConfigPath');
198
219
  export const yarnRun = wrap(__, 'yarnRun');
199
220
  export const run = wrap(__, 'run');
package/lib/main.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Helper
2
2
  export { findHostFiles } from './helper.js';
3
3
  export { getConfig } from './helper.js';
4
+ export { getConfigPath } from './helper.js';
4
5
  export { hostGitPath } from './helper.js';
5
6
  export { hostGitRoot } from './helper.js';
6
7
  export { hostPackagePath } from './helper.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aberlaas-helper",
3
- "version": "2.40.0",
3
+ "version": "2.41.1",
4
4
  "type": "module",
5
5
  "description": "aberlaas shared helper: Common methods used by all commands",
6
6
  "author": "Tim Carry <tim@pixelastic.com>",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "main": "./lib/main.js",
21
21
  "dependencies": {
22
- "aberlaas-versions": "2.40.0",
22
+ "aberlaas-versions": "2.41.1",
23
23
  "firost": "5.11.0",
24
24
  "golgoth": "4.0.0"
25
25
  },