-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into huijbers/event-bus-name
- Loading branch information
Showing
3 changed files
with
97 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { exec as _exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
import * as semver from 'semver'; | ||
import { debug } from '../../lib/logging'; | ||
|
||
const exec = promisify(_exec); | ||
|
||
export async function getLatestVersionFromNpm(): Promise<string> { | ||
const { stdout, stderr } = await exec('npm view aws-cdk version'); | ||
if (stderr && stderr.trim().length > 0) { | ||
debug(`The 'npm view' command generated an error stream with content [${stderr.trim()}]`); | ||
} | ||
const latestVersion = stdout.trim(); | ||
if (!semver.valid(latestVersion)) { | ||
throw new Error(`npm returned an invalid semver ${latestVersion}`); | ||
} | ||
|
||
return latestVersion; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters