nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: artusjs/core
Pull request #59 (2022-05-09 08:00:18)

fix: should ignore d.ts
`tsc` 打包后会默认生成 `.d.ts` 声明文件，此时 Scanner 扫描 config 目录时对于 `plugin.ts` 等默认 Env 配置会错误扫描 `plugin.d.ts` 从而得到 Env `d`：

```js
{
  default: {
    items: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object]
    ]
  },
  d: {
    items: [
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object],
      [Object], [Object]
    ]
  }
}
```

需要在 Scanner 中忽略 `.d.ts` 申明文件



Patch:
diff --git a/src/index.ts b/src/index.ts
index 6322b38..00c3d54 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -18,6 +18,9 @@ export * from './decorator';
 export * from './types';
 export * from './constraints';
 
+import ConfigurationHandler from './configuration';
+export { ConfigurationHandler };
+
 import Trigger from './trigger';
 export { Trigger };
 
diff --git a/src/scanner/scan.ts b/src/scanner/scan.ts
index d9c3bc3..90de28b 100644
--- a/src/scanner/scan.ts
+++ b/src/scanner/scan.ts
@@ -59,6 +59,9 @@ export class Scanner {
         const configFileList = await fs.readdir(path.resolve(root, configDir));
         const envSet: Set<string> = new Set([ARTUS_DEFAULT_CONFIG_ENV.DEFAULT]);
         for (const configFilename of configFileList) {
+            if(configFilename.endsWith('.d.ts')){
+              continue;
+            }
           const env = ConfigurationHandler.getEnvFromFilename(configFilename);
           envSet.add(env);
         }


Test patch:
diff --git a/test/fixtures/app-koa-with-ts/src/config/plugin.d.ts b/test/fixtures/app-koa-with-ts/src/config/plugin.d.ts
new file mode 100644
index 0000000..c085239
--- /dev/null
+++ b/test/fixtures/app-koa-with-ts/src/config/plugin.d.ts
@@ -0,0 +1,7 @@
+declare const _default: {
+  redis: {
+      enable: boolean;
+      package: string;
+  };
+};
+export default _default;
diff --git a/test/scanner.test.ts b/test/scanner.test.ts
index 5204494..94431f5 100644
--- a/test/scanner.test.ts
+++ b/test/scanner.test.ts
@@ -5,7 +5,9 @@ import path from 'path';
 describe('test/scanner.test.ts', () => {
     it('should scan application', async () => {
         const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
-        const { default: manifest } = await scanner.scan(path.resolve(__dirname, './fixtures/app-koa-with-ts'));
+        const scanResults = await scanner.scan(path.resolve(__dirname, './fixtures/app-koa-with-ts'));
+        const { default: manifest } = scanResults;
+        expect(Object.entries(scanResults).length).toBe(1);
         expect(manifest).toBeDefined();
         expect(manifest.items).toBeDefined();
         // console.log('manifest', manifest);
Repository: artusjs/core
Pull request #60 (2022-05-10 07:25:33)

feat(scanner): 支持自定义 Loader 场景


Patch:
diff --git a/src/scanner/scan.ts b/src/scanner/scan.ts
index 90de28b..be690b2 100644
--- a/src/scanner/scan.ts
+++ b/src/scanner/scan.ts
@@ -34,6 +34,7 @@ export class Scanner {
             appName: 'app',
             needWriteFile: true,
             configDir: DEFAULT_CONFIG_DIR,
+            loaderListGenerator: (defaultLoaderList: string[]) => defaultLoaderList,
             ...options,
             excluded: DEFAULT_EXCLUDES.concat(options.excluded ?? []),
             extensions: [...new Set(this.moduleExtensions.concat(options.extensions ?? [], ['.yaml']))],
@@ -41,7 +42,10 @@ export class Scanner {
 
         this.checkOptions();
 
-        this.itemMap = new Map(DEFAULT_LOADER_LIST_WITH_ORDER.map((loaderName) => ([loaderName, []])));
+        this.itemMap = new Map(
+          this.options.loaderListGenerator(DEFAULT_LOADER_LIST_WITH_ORDER)
+            .map((loaderName) => ([loaderName, []]))
+        );
         this.loaderFactory = LoaderFactory.create(new Container(ArtusInjectEnum.DefaultContainerName));
     }
 
diff --git a/src/scanner/types.ts b/src/scanner/types.ts
index 72cbe66..d2126c6 100644
--- a/src/scanner/types.ts
+++ b/src/scanner/types.ts
@@ -3,8 +3,9 @@ export interface ScannerOptions {
   extensions: string[];
   needWriteFile: boolean;
   excluded?: string[];
-  configDir: string
+  configDir: string;
   envs?: string[];
+  loaderListGenerator: (defaultLoaderList: string[]) => string[];
 }
 
 export interface WalkOptions {


Test patch:
diff --git a/test/scanner.test.ts b/test/scanner.test.ts
index 94431f5..3fce73e 100644
--- a/test/scanner.test.ts
+++ b/test/scanner.test.ts
@@ -24,4 +24,18 @@ describe('test/scanner.test.ts', () => {
         expect(manifest.items.filter(item => item.unitName === 'mysql').length).toBe(0);
         expect(manifest.items.filter(item => item.source === 'app').length).toBe(10);
     });
+
+    it('should scan module with custom loader', async () => {
+      await import('./fixtures/module-with-custom-loader/src');
+      const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'], configDir: '.', loaderListGenerator: () => ['test-custom-loader'] });
+      const scanResults = await scanner.scan(path.resolve(__dirname, './fixtures/module-with-custom-loader'));
+      const { default: manifest } = scanResults;
+      // console.log('manifest', manifest);
+      expect(Object.entries(scanResults).length).toBe(1);
+      expect(manifest).toBeDefined();
+      expect(manifest.items).toBeDefined();
+      expect(Array.isArray(manifest.items)).toBe(true);
+      expect(manifest.items.length).toBe(1);
+      expect(manifest.items[0]?.loader).toBe('test-custom-loader');
+    });
 });
Repository: artusjs/core
Pull request #235 (2023-03-06 06:27:50)

fix(scanner): support relative path as root


Patch:
diff --git a/src/scanner/scan.ts b/src/scanner/scan.ts
index 4b37181..aae459b 100644
--- a/src/scanner/scan.ts
+++ b/src/scanner/scan.ts
@@ -82,6 +82,11 @@ export class Scanner {
   }
 
   async scan(root: string): Promise<Record<string, Manifest>> {
+    if (!path.isAbsolute(root)) {
+      // make sure the root path is absolute
+      root = path.resolve(root);
+    }
+
     const result = {};
     const envList = await this.scanEnvList(root);
 


Test patch:
diff --git a/test/scanner.test.ts b/test/scanner.test.ts
index beaeb18..84887c3 100644
--- a/test/scanner.test.ts
+++ b/test/scanner.test.ts
@@ -47,6 +47,14 @@ describe('test/scanner.test.ts', () => {
     });
   });
 
+  it('should scan test dir by relative path', async () => {
+    const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
+    const relativeRoot = path.relative(process.cwd(), __dirname);
+    const scanResults = await scanner.scan(path.join(relativeRoot, './fixtures/app_koa_with_ts'));
+    expect(scanResults?.default?.items).toBeDefined();
+    expect(scanResults?.dev?.items).toBeDefined();
+  });
+
   it('should not scan test dir', async () => {
     const scanner = new Scanner({ needWriteFile: false, extensions: ['.ts', '.js', '.json'] });
     const scanResults = await scanner.scan(path.resolve(__dirname, './fixtures/app_with_lifecycle'));
Repository: oclif/core
Pull request #414 (2022-05-03 21:31:43)

fix bug where custom flags do not respect multiple option
Currently, custom flags do not honor the `multiple` option. This fixes the issue by only overriding the `multiple` default if explicitly provided in `options`.

salesforce-cla[bot]: Thanks for the contribution!  Before we can merge this, we need @rolyatmax to [sign the Salesforce.com Contributor License Agreement](https://cla.salesforce.com/sign-cla?prUrl=https%3A%2F%2Fgithub.com%2Foclif%2Fcore%2Fpull%2F414).

Patch:
diff --git a/src/parser/flags.ts b/src/parser/flags.ts
index 286e06e..b6bdc8d 100644
--- a/src/parser/flags.ts
+++ b/src/parser/flags.ts
@@ -18,7 +18,7 @@ export function build<T>(defaults: Partial<OptionFlag<T>>): Definition<T> {
       ...defaults,
       ...options,
       input: [] as string[],
-      multiple: Boolean(options.multiple),
+      multiple: Boolean(options.multiple === undefined ? defaults.multiple : options.multiple),
       type: 'option',
     } as any
   }


Test patch:
diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts
index b705a03..0fc6d48 100644
--- a/test/parser/parse.test.ts
+++ b/test/parser/parse.test.ts
@@ -327,6 +327,14 @@ See more help with --help`)
         expect(out.flags.baz.toUpperCase()).to.equal('D')
         expect(out.flags.bar.join('|')).to.equal('a|b')
       })
+      it('parses multiple flags on custom flags', async () => {
+        const out = await parse(['--foo', 'a', '--foo=b'], {
+          flags: {
+            foo: flags.option({multiple: true, parse: async i => i}),
+          },
+        })
+        expect(out.flags).to.deep.include({foo: ['a', 'b']})
+      })
     })
 
     describe('strict: false', () => {
Repository: oclif/core
Pull request #642 (2023-02-28 17:49:44)

feat: add option to skip oclif error printing
Add ability to skip error logging during final error handler

@W-12615284@


Patch:
diff --git a/src/errors/handle.ts b/src/errors/handle.ts
index 08df662..2af24d1 100644
--- a/src/errors/handle.ts
+++ b/src/errors/handle.ts
@@ -7,12 +7,12 @@ import clean = require('clean-stack')
 import {CLIError} from './errors/cli'
 import {OclifError, PrettyPrintableError} from '../interfaces'
 
-export const handle = (err: Error & Partial<PrettyPrintableError> & Partial<OclifError>): void => {
+export const handle = (err: Error & Partial<PrettyPrintableError> & Partial<OclifError> & {skipOclifErrorHandling?: boolean}): void => {
   try {
     if (!err) err = new CLIError('no error?')
     if (err.message === 'SIGINT') process.exit(1)
 
-    const shouldPrint = !(err instanceof ExitError)
+    const shouldPrint = !(err instanceof ExitError) && !err.skipOclifErrorHandling
     const pretty = prettyPrint(err)
     const stack = clean(err.stack || '', {pretty: true})
 


Test patch:
diff --git a/test/errors/handle.test.ts b/test/errors/handle.test.ts
index 556408b..90afe53 100644
--- a/test/errors/handle.test.ts
+++ b/test/errors/handle.test.ts
@@ -70,6 +70,28 @@ describe('handle', () => {
     expect(process.exitCode).to.equal(0)
   })
 
+  fancy
+  .stdout()
+  .stderr()
+  .it('prints error', ctx => {
+    const error = new Error('foo bar baz') as Error & {skipOclifErrorHandling: boolean}
+    error.skipOclifErrorHandling = false
+    handle(error)
+    expect(ctx.stdout).to.equal('')
+    expect(ctx.stderr).to.include('foo bar baz')
+  })
+
+  fancy
+  .stdout()
+  .stderr()
+  .it('should not print error when skipOclifErrorHandling is true', ctx => {
+    const error = new Error('foo bar baz') as Error & {skipOclifErrorHandling: boolean}
+    error.skipOclifErrorHandling = true
+    handle(error)
+    expect(ctx.stdout).to.equal('')
+    expect(ctx.stderr).to.equal('')
+  })
+
   fancy
   .stderr()
   .do(() => {
Repository: oclif/core
Pull request #657 (2023-03-13 12:45:54)

fix: handle undefined env.SHELL on ubuntu tests
@W-12647786@


Patch:
diff --git a/src/config/config.ts b/src/config/config.ts
index cdde8ea..6f3aafb 100644
--- a/src/config/config.ts
+++ b/src/config/config.ts
@@ -18,6 +18,8 @@ import {CompletableOptionFlag, Arg} from '../interfaces/parser'
 import {stdout} from '../cli-ux/stream'
 import {Performance} from '../performance'
 import {settings} from '../settings'
+import {userInfo as osUserInfo} from 'node:os'
+import {sep} from 'node:path'
 
 // eslint-disable-next-line new-cap
 const debug = Debug()
@@ -550,7 +552,8 @@ export class Config implements IConfig {
 
   protected _shell(): string {
     let shellPath
-    const {SHELL, COMSPEC} = process.env
+    const COMSPEC = process.env.COMSPEC
+    const SHELL = process.env.SHELL ?? osUserInfo().shell?.split(sep)?.pop()
     if (SHELL) {
       shellPath = SHELL.split('/')
     } else if (this.windows && COMSPEC) {


Test patch:
diff --git a/test/config/config.shell.test.ts b/test/config/config.shell.test.ts
new file mode 100644
index 0000000..421105c
--- /dev/null
+++ b/test/config/config.shell.test.ts
@@ -0,0 +1,14 @@
+import {expect} from 'chai'
+import {Config} from '../../src'
+import {userInfo as osUserInfo} from 'node:os'
+import {sep} from 'node:path'
+
+const getShell = () => osUserInfo().shell?.split(sep)?.pop() || 'unknown'
+
+describe('config shell', () => {
+  it('has a default shell', () => {
+    const config = new Config({root: '/tmp'})
+    // @ts-ignore
+    expect(config._shell()).to.equal(getShell(), `SHELL: ${process.env.SHELL} COMSPEC: ${process.env.COMSPEC}`)
+  })
+})
Repository: oclif/core
Pull request #730 (2023-07-12 15:18:42)

fix: flags omit undefined for boolean flags
fix https://github.com/oclif/core/issues/729

[boolean flags have a built-in `parse` function even if the user doesn't specify it.  It was easier to filter out `undefined` flags after calculating all the valus than to try to interfere with boolean flags before the `default` logic happens]


Patch:
diff --git a/perf.txt b/perf.txt
deleted file mode 100644
index 5c7d34b..0000000
--- a/perf.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-yarn run v1.22.19
-$ ts-node test/perf/parser.perf.ts
-simple x 131,268 ops/sec ±1.15% (79 runs sampled)
-multiple async flags that take time x 9.90 ops/sec ±0.14% (50 runs sampled)
-flagstravaganza x 7,425 ops/sec ±2.10% (83 runs sampled)
-Done in 21.60s.
diff --git a/src/parser/parse.ts b/src/parser/parse.ts
index 218aa50..410ef7b 100644
--- a/src/parser/parse.ts
+++ b/src/parser/parse.ts
@@ -317,7 +317,10 @@ export class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']
       return Promise.all(fws.map(async fws => fws.helpFunction ? ({...fws, metadata: {...fws.metadata, defaultHelp: await fws.helpFunction?.(fws, valueReferenceForHelp, this.context)}}) : fws))
     }
 
-    const fwsArrayToObject = (fwsArray: FlagWithStrategy[]) => Object.fromEntries(fwsArray.map(fws => [fws.inputFlag.name, fws.value]))
+    const fwsArrayToObject = (fwsArray: FlagWithStrategy[]) => Object.fromEntries(
+      fwsArray.filter(fws => fws.value !== undefined)
+      .map(fws => [fws.inputFlag.name, fws.value]),
+    )
 
     type FlagWithStrategy = {
       inputFlag: {


Test patch:
diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts
index 62c8eaa..06e3852 100644
--- a/test/parser/parse.test.ts
+++ b/test/parser/parse.test.ts
@@ -22,6 +22,29 @@ describe('parse', () => {
     expect(out).to.deep.include({flags: {bool: true}})
   })
 
+  describe('undefined flags', () => {
+    it('omits undefined flags when no flags', async () => {
+      const out = await parse([], {
+        flags: {
+          bool: Flags.boolean(),
+        },
+      })
+      expect(out.flags).to.deep.equal({})
+    })
+
+    it('omits undefined flags when some flags exist', async () => {
+      const out = await parse(['--bool', '--str', 'k'], {
+        flags: {
+          bool: Flags.boolean(),
+          bool2: Flags.boolean(),
+          str: Flags.string(),
+          str2: Flags.string(),
+        },
+      })
+      expect(out.flags).to.deep.equal({bool: true, str: 'k'})
+    })
+  })
+
   it('arg1', async () => {
     const out = await parse(['arg1'], {
       args: {foo: Args.string()},
Repository: oclif/core
Pull request #734 (2023-07-13 17:49:09)

Allow empty flag default
Allow an empty string as a flag default. Used in a few places and caused NUTs to fail
https://github.com/salesforcecli/plugin-community/blob/main/src/commands/community/create.ts#L60
https://github.com/salesforcecli/plugin-custom-metadata/blob/main/src/commands/cmdt/generate/object.ts#L64

[@W-13754930@](https://gus.my.salesforce.com/apex/ADM_WorkLocator?bugorworknumber=W-13754930)


Patch:
diff --git a/src/parser/parse.ts b/src/parser/parse.ts
index 2d83b37..b3aa0c1 100644
--- a/src/parser/parse.ts
+++ b/src/parser/parse.ts
@@ -351,10 +351,9 @@ export class Parser<T extends ParserInput, TFlags extends OutputFlags<T['flags']
     }
 
     const flagTokenMap = this.mapAndValidateFlags()
-
     const flagsWithValues = await Promise.all(Object.entries(this.input.flags)
     // we check them if they have a token, or might have env, default, or defaultHelp.  Also include booleans so they get their default value
-    .filter(([name, flag]) => flag.type === 'boolean' || flag.env || flag.default || 'defaultHelp' in flag || flagTokenMap.has(name))
+    .filter(([name, flag]) => flag.type === 'boolean' || flag.env || flag.default !== undefined || 'defaultHelp' in flag || flagTokenMap.has(name))
     // match each possible flag to its token, if there is one
     .map(([name, flag]): FlagWithStrategy => ({inputFlag: {name, flag}, tokens: flagTokenMap.get(name)}))
     .map(fws => addValueFunction(fws))


Test patch:
diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts
index e65f80a..c124693 100644
--- a/test/parser/parse.test.ts
+++ b/test/parser/parse.test.ts
@@ -971,6 +971,25 @@ See more help with --help`)
       expect(out.args).to.deep.include({baz: false})
     })
 
+    it('accepts falsy flags', async () => {
+      const out = await parse([], {
+        flags: {
+          foo1: Flags.string({default: ''}),
+          foo2: Flags.string({default: '0'}),
+          foo3: Flags.string({default: 'false'}),
+          foo4: Flags.string({default: 'undefined'}),
+          bar: Flags.integer({default: 0}),
+          baz: Flags.boolean({default: false}),
+        },
+      })
+      expect(out.flags).to.deep.include({foo1: ''})
+      expect(out.flags).to.deep.include({foo2: '0'})
+      expect(out.flags).to.deep.include({foo3: 'false'})
+      expect(out.flags).to.deep.include({foo4: 'undefined'})
+      expect(out.flags).to.deep.include({bar: 0})
+      expect(out.flags).to.deep.include({baz: false})
+    })
+
     it('default as function', async () => {
       const out = await parse([], {
         args: {baz: Args.string({default: async () => 'BAZ'})},
Repository: oclif/core
Pull request #834 (2023-10-17 21:36:16)

feat: don't error on exit code 0
Don't throw error on exit code `0`

Closes #660

(Passing tests depend on https://github.com/oclif/core/pull/836)


Patch:
diff --git a/src/command.ts b/src/command.ts
index bef7ea9..86380b2 100644
--- a/src/command.ts
+++ b/src/command.ts
@@ -211,7 +211,9 @@ export abstract class Command {
     return Errors.error(input, options as any)
   }
 
-  public exit(code = 0): never {
+  public exit(code: number): never
+  public exit(code: 0): void
+  public exit(code = 0): void | never {
     Errors.exit(code)
   }
 
diff --git a/src/errors/index.ts b/src/errors/index.ts
index ce120a5..873d616 100644
--- a/src/errors/index.ts
+++ b/src/errors/index.ts
@@ -11,8 +11,10 @@ export {ExitError} from './errors/exit'
 export {ModuleLoadError} from './errors/module-load'
 export {handle} from './handle'
 
-export function exit(code = 0): never {
-  throw new ExitError(code)
+export function exit(code = 0) {
+  if (code !== 0) {
+    throw new ExitError(code)
+  }
 }
 
 export function error(input: Error | string, options: {exit: false} & PrettyPrintableError): void


Test patch:
diff --git a/test/command/command.test.ts b/test/command/command.test.ts
index 35f33ea..c86f333 100644
--- a/test/command/command.test.ts
+++ b/test/command/command.test.ts
@@ -68,8 +68,7 @@ describe('command', () => {
 
       return Command.run([])
     })
-    .catch(/EEXIT: 0/)
-    .it('exits with 0')
+    .it('exits with 0 does not throw error')
 
   describe('parse', () => {
     fancy.stdout().it('has a flag', async (ctx) => {
Repository: oclif/core
Pull request #980 (2024-03-01 16:49:55)

fix: correctly escapes double quotes when converting ux.table to csv (#977)
Merges #977 

* Fix: correctly escapes double quotes when converting ux.table to csv

modify replace with replaceAll as mentioned in this issue : https://github.com/oclif/core/issues/944#issue-2126189996

* test: complete ux.table test to check if double quotes escaping is correct


Patch:
diff --git a/src/cli-ux/styled/table.ts b/src/cli-ux/styled/table.ts
index 1db3ba0..c708753 100644
--- a/src/cli-ux/styled/table.ts
+++ b/src/cli-ux/styled/table.ts
@@ -150,7 +150,7 @@ class Table<T extends Record<string, unknown>> {
     const lineToBeEscaped = values.find(
       (e: string) => e.includes('"') || e.includes('\n') || e.includes('\r\n') || e.includes('\r') || e.includes(','),
     )
-    return values.map((e) => (lineToBeEscaped ? `"${e.replace('"', '""')}"` : e))
+    return values.map((e) => (lineToBeEscaped ? `"${e.replaceAll('"', '""')}"` : e))
   }
 
   private outputCSV() {


Test patch:
diff --git a/test/cli-ux/styled/table.test.ts b/test/cli-ux/styled/table.test.ts
index 1505846..c32ef23 100644
--- a/test/cli-ux/styled/table.test.ts
+++ b/test/cli-ux/styled/table.test.ts
@@ -158,13 +158,17 @@ describe('styled/table', () => {
             id: '12"3',
             name: 'supertable-test-2',
           },
+          {
+            id: '1"2"3',
+            name: 'supertable-test-3',
+          },
           {
             id: '123',
-            name: 'supertable-test-3,comma',
+            name: 'supertable-test-4,comma',
           },
           {
             id: '123',
-            name: 'supertable-test-4',
+            name: 'supertable-test-5',
           },
         ],
         columns,
@@ -173,8 +177,9 @@ describe('styled/table', () => {
       expect(output.stdout).to.equal(`ID,Name
 "123\n2","supertable-test-1"
 "12""3","supertable-test-2"
-"123","supertable-test-3,comma"
-123,supertable-test-4\n`)
+"1""2""3","supertable-test-3"
+"123","supertable-test-4,comma"
+123,supertable-test-5\n`)
     })
 
     fancy.stdout().end('outputs in csv without headers', (output) => {
Repository: oclif/core
Pull request #1047 (2024-04-08 18:20:19)

fix: do not throw an error if a flag with allowStdin='only' is immediately followed by another flag (#1046)
Merges #1046 

Fixes https://github.com/forcedotcom/cli/issues/2811


Patch:
diff --git a/src/parser/parse.ts b/src/parser/parse.ts
index 2374471..037b652 100644
--- a/src/parser/parse.ts
+++ b/src/parser/parse.ts
@@ -173,7 +173,7 @@ export class Parser<
         this.currentFlag = flag
         let input = isLong || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2)
 
-        if (flag.allowStdin === 'only' && input !== '-' && input !== undefined) {
+        if (flag.allowStdin === 'only' && input !== '-' && input !== undefined && !this.findFlag(input).name) {
           throw new CLIError(
             `Flag --${name} can only be read from stdin. The value must be "-" or not provided at all.`,
           )


Test patch:
diff --git a/test/parser/parse.test.ts b/test/parser/parse.test.ts
index abcb3f1..c5022e4 100644
--- a/test/parser/parse.test.ts
+++ b/test/parser/parse.test.ts
@@ -1956,4 +1956,17 @@ describe('allowStdin', () => {
       }
     }
   })
+
+  it('should read stdin as input for flag when allowStdin is "only" and no value is given, and a second flag is used after', async () => {
+    sandbox.stub(parser, 'readStdin').returns(stdinPromise)
+    const out = await parse(['--myflag', '--myflag2'], {
+      flags: {
+        myflag: Flags.string({allowStdin: 'only'}),
+        myflag2: Flags.boolean(),
+      },
+    })
+
+    expect(out.flags.myflag).to.equals(stdinValue)
+    expect(out.raw[0].input).to.equal('x')
+  })
 })