Skip to content

Commit a0d886e

Browse files
committed
execSync
1 parent 849536b commit a0d886e

File tree

1 file changed

+9
-15
lines changed
  • packages/aws-cdk/lib/cli/util

1 file changed

+9
-15
lines changed

packages/aws-cdk/lib/cli/util/npm.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
import { exec as _exec } from 'child_process';
2-
import { promisify } from 'util';
1+
import { execSync } from 'child_process';
32
import { ToolkitError } from '@aws-cdk/toolkit-lib';
43

5-
const exec = promisify(_exec);
6-
74
/* c8 ignore start */
85
export async function execNpmView(currentVersion: string) {
96
try {
10-
// eslint-disable-next-line @cdklabs/promiseall-no-unbounded-parallelism
11-
const [latestResult, currentResult] = await Promise.all([
12-
exec('npm view aws-cdk@latest version', { timeout: 3000 }),
13-
exec(`npm view aws-cdk@${currentVersion} name version deprecated --json`, { timeout: 3000 }),
14-
]);
7+
const latestResult = execSync('npm view aws-cdk@latest version', { timeout: 3000 }).toString();
8+
const currentResult = execSync(`npm view aws-cdk@${currentVersion} name version deprecated --json`, { timeout: 3000 }).toString();
159

16-
if (latestResult.stderr && latestResult.stderr.trim().length > 0) {
17-
throw new ToolkitError(`npm view command for latest version failed: ${latestResult.stderr.trim()}`);
10+
if (latestResult && latestResult.trim().length > 0) {
11+
throw new ToolkitError(`npm view command for latest version failed: ${latestResult.trim()}`);
1812
}
19-
if (currentResult.stderr && currentResult.stderr.trim().length > 0) {
20-
throw new ToolkitError(`npm view command for current version failed: ${currentResult.stderr.trim()}`);
13+
if (currentResult && currentResult.trim().length > 0) {
14+
throw new ToolkitError(`npm view command for current version failed: ${currentResult.trim()}`);
2115
}
2216

23-
const latestVersion = latestResult.stdout;
24-
const currentInfo = JSON.parse(currentResult.stdout);
17+
const latestVersion = latestResult;
18+
const currentInfo = JSON.parse(currentResult);
2519

2620
return {
2721
latestVersion: latestVersion,

0 commit comments

Comments
 (0)