Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe('PassThroughService', () => {
await program.parseAsync([name, ...argv], {from: 'user'})
expect(childProcess.spawn).toHaveBeenNthCalledWith(
1,
'docker run --rm -v "/foo/bar:/local" openapitools/openapi-generator-cli:v4.2.1',
expect.stringMatching(/docker run --rm -v "\/foo\/bar:\/local" --user \d+:\d+ openapitools\/openapi-generator-cli:v4.2.1/),
[name, ...argv],
{
stdio: 'inherit',
Expand Down
5 changes: 5 additions & 0 deletions apps/generator-cli/src/app/services/pass-through.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as chalk from 'chalk'
import {exec, spawn} from 'child_process'
import {Command} from 'commander'
import {isString, startsWith, trim} from 'lodash'
import * as os from 'os';
import {COMMANDER_PROGRAM, LOGGER} from '../constants'
import {GeneratorService} from './generator.service'
import {VersionManagerService} from './version-manager.service'
Expand Down Expand Up @@ -117,8 +118,12 @@ export class PassThroughService {

private cmd() {
if (this.configService.useDocker) {
const userInfo = os.userInfo();
const userArg = userInfo.uid !== -1 ? `--user ${userInfo.uid}:${userInfo.gid}` : ``;

return [
`docker run --rm -v "${this.configService.cwd}:/local"`,
userArg,
this.versionManager.getDockerImageName(),
].join(' ');
}
Expand Down