src/cli/enforce-global.js
function defaultVersionMatcher(raw) {
  // sanity check
  if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null

  try {
    // look for something that looks like semver
    var rx = /([0-9]+\.[0-9]+\.[0-9]+)/
    var match = ramda.match(rx, raw)
    if (match.length > 0) {
      return match[0]
    } else {
      return null
    }
  } catch (err) {
    // something tragic happened
    return false
  }
}
function defaultVersionMatcher(raw) {
  // sanity check
  if (ramda.isNil(raw) || ramda.isEmpty(raw)) return null

  try {
    // look for something that looks like semver
    var rx = /([0-9]+\.[0-9]+\.[0-9]+)/
    var match = ramda.match(rx, raw)
    if (match.length > 0) {
      return match[0]
    } else {
      return null
    }
  } catch (err) {
    // something tragic happened
    return false
  }
}
function defaultVersionMatcher ( raw ) { // sanity check if ( ramda . isNil ( raw ) || ramda . isEmpty ( raw ) ) return null try { // look for something that looks like semver var rx = / ([0-9]+\.[0-9]+\.[0-9]+) / var match = ramda . match ( rx , raw ) if ( match . length > 0 ) { return match [ 0 ] } else { return null } } catch ( err ) { // something tragic happened return false } }
Extracts the version number from a somewhere within a string.

This looks for things that look like semver (e.g. 0.0.0) and picks the first one.

@param {string} raw - The raw text which came from running the version command.
Extracts the version number from a somewhere within a string .