'use strict' ; import * as semver from 'semver' ; import { Version } from '../types' ; export function parseVersion ( raw ) { raw = raw . replace ( /\.00*(?=[1-9]|0\.)/ , '.' ) ; const ver = semver . coerce ( raw ) ; if ( ver === null || ! semver . valid ( ver ) ) { return new semver . SemVer ( '0.0.0' ) ; } return ver ; }