Skip to content

Commit

Permalink
fix: add dynamic extension for specs file name at sdk create
Browse files Browse the repository at this point in the history
  • Loading branch information
mrednic-1A committed May 21, 2024
1 parent 6a41539 commit c2670ff
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/@ama-sdk/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable no-console */

import { execSync, spawnSync } from 'node:child_process';
import { dirname, join, parse, relative, resolve } from 'node:path';
import { dirname, extname, join, parse, relative, resolve } from 'node:path';
import * as minimist from 'minimist';

const packageManagerEnv = process.env.npm_config_user_agent?.split('/')[0];
Expand Down Expand Up @@ -65,6 +65,11 @@ if (argv['spec-path'] && argv['spec-package-name']) {
process.exit(-4);
}

if (argv['spec-package-name'] && !argv['spec-package-path']) {
console.error('--spec-package-name cannot be used without --spec-package-path');
process.exit(-5);
}

const commonSchematicArgs = [
argv.debug !== undefined ? `--debug=${argv.debug as string}` : '--debug=false', // schematics enable debug mode per default when using schematics with relative path
...(name ? ['--name', name] : []),
Expand All @@ -88,7 +93,8 @@ const run = () => {
];
const coreSchematicArgs = [
...commonSchematicArgs,
'--spec-path', argv['spec-package-name'] ? './openapi.yml' : isSpecRelativePath ? relative(resolveTargetDirectory, resolve(process.cwd(), argv['spec-path'])) : argv['spec-path']
'--spec-path',
argv['spec-package-name'] ? `./openapi${extname(argv['spec-package-path'])}` : isSpecRelativePath ? relative(resolveTargetDirectory, resolve(process.cwd(), argv['spec-path'])) : argv['spec-path']
];

const runner = process.platform === 'win32' ? `${packageManager}.cmd` : packageManager;
Expand Down

0 comments on commit c2670ff

Please sign in to comment.