@oclif/core 2.10.1 → 2.11.0

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/command.js CHANGED
@@ -112,7 +112,7 @@ class Command {
112
112
  let result;
113
113
  try {
114
114
  // remove redirected env var to allow subsessions to run autoupdated client
115
- delete process.env[this.config.scopedEnvVarKey('REDIRECTED')];
115
+ this.config.scopedEnvVarKeys('REDIRECTED').map(key => delete process.env[key]);
116
116
  await this.init();
117
117
  result = await this.run();
118
118
  }
@@ -50,7 +50,18 @@ export declare class Config implements IConfig {
50
50
  runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Loadable | null): Promise<T>;
51
51
  scopedEnvVar(k: string): string | undefined;
52
52
  scopedEnvVarTrue(k: string): boolean;
53
+ /**
54
+ * this DOES NOT account for bin aliases, use scopedEnvVarKeys instead which will account for bin aliases
55
+ * @param {string} k, the unscoped key you want to get the value for
56
+ * @returns {string} returns the env var key
57
+ */
53
58
  scopedEnvVarKey(k: string): string;
59
+ /**
60
+ * gets the scoped env var keys for a given key, including bin aliases
61
+ * @param {string} k, the env key e.g. 'debug'
62
+ * @returns {string[]} e.g. ['SF_DEBUG', 'SFDX_DEBUG']
63
+ */
64
+ scopedEnvVarKeys(k: string): string[];
54
65
  findCommand(id: string, opts: {
55
66
  must: true;
56
67
  }): Command.Loadable;
@@ -333,18 +333,31 @@ class Config {
333
333
  return result;
334
334
  }
335
335
  scopedEnvVar(k) {
336
- return process.env[this.scopedEnvVarKey(k)];
336
+ return process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
337
337
  }
338
338
  scopedEnvVarTrue(k) {
339
- const v = process.env[this.scopedEnvVarKey(k)];
339
+ const v = process.env[this.scopedEnvVarKeys(k).find(k => process.env[k])];
340
340
  return v === '1' || v === 'true';
341
341
  }
342
+ /**
343
+ * this DOES NOT account for bin aliases, use scopedEnvVarKeys instead which will account for bin aliases
344
+ * @param {string} k, the unscoped key you want to get the value for
345
+ * @returns {string} returns the env var key
346
+ */
342
347
  scopedEnvVarKey(k) {
343
348
  return [this.bin, k]
344
349
  .map(p => p.replace(/@/g, '').replace(/[/-]/g, '_'))
345
350
  .join('_')
346
351
  .toUpperCase();
347
352
  }
353
+ /**
354
+ * gets the scoped env var keys for a given key, including bin aliases
355
+ * @param {string} k, the env key e.g. 'debug'
356
+ * @returns {string[]} e.g. ['SF_DEBUG', 'SFDX_DEBUG']
357
+ */
358
+ scopedEnvVarKeys(k) {
359
+ return [this.bin, ...this.binAliases ?? []].map(alias => [alias.replace(/@/g, '').replace(/[/-]/g, '_'), k].join('_').toUpperCase());
360
+ }
348
361
  findCommand(id, opts = {}) {
349
362
  const lookupId = this.getCmdLookupId(id);
350
363
  const command = this._commands.get(lookupId);
@@ -130,6 +130,7 @@ export interface Config {
130
130
  findMatches(id: string, argv: string[]): Command.Loadable[];
131
131
  scopedEnvVar(key: string): string | undefined;
132
132
  scopedEnvVarKey(key: string): string;
133
+ scopedEnvVarKeys(key: string): string[];
133
134
  scopedEnvVarTrue(key: string): boolean;
134
135
  s3Url(key: string): string;
135
136
  s3Key(type: 'versioned' | 'unversioned', ext: '.tar.gz' | '.tar.xz', options?: Config.s3Key.Options): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "2.10.1",
4
+ "version": "2.11.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {