thali/install/validateBuildEnvironment.js
function checkVersion(objectName, versionNumber) {
  const desiredVersion = versionNumber ? versionNumber : versions[objectName];
  const commandAndResult = commandsAndResults[objectName];
  if (!commandAndResult) {
    return Promise.reject(
      new Error('Unrecognized objectName in commandsAndResults'));
  }
  if (!desiredVersion) {
    return Promise.reject(new Error('Unrecognized objectName in versions'));
  }
  if (commandAndResult.platform &&
      !commandAndResult.platform.includes(os.platform()))
  {
    return Promise.reject(new Error('Requested object is not supported on ' +
      'this platform'));
  }
  if (typeof commandAndResult.versionCheck === 'function') {
    return promiseTry(commandAndResult.versionCheck)
      .catch(() =>
        Promise.reject(new Error('Version Check failed on ' + objectName)))
      .then((versionCheckResult) =>
        commandAndResult.versionValidate(versionCheckResult, desiredVersion))
      .then(() => Promise.resolve(true))
      .catch(() => Promise.reject(
                        new Error('Version not installed of ' + objectName)));
  }
  return execAndCheck(commandAndResult.versionCheck,
                      commandAndResult.checkStdErr,
                      desiredVersion,
                      commandAndResult.versionValidate);
}
function checkVersion(objectName, versionNumber) {
  const desiredVersion = versionNumber ? versionNumber : versions[objectName];
  const commandAndResult = commandsAndResults[objectName];
  if (!commandAndResult) {
    return Promise.reject(
      new Error('Unrecognized objectName in commandsAndResults'));
  }
  if (!desiredVersion) {
    return Promise.reject(new Error('Unrecognized objectName in versions'));
  }
  if (commandAndResult.platform &&
      !commandAndResult.platform.includes(os.platform()))
  {
    return Promise.reject(new Error('Requested object is not supported on ' +
      'this platform'));
  }
  if (typeof commandAndResult.versionCheck === 'function') {
    return promiseTry(commandAndResult.versionCheck)
      .catch(() =>
        Promise.reject(new Error('Version Check failed on ' + objectName)))
      .then((versionCheckResult) =>
        commandAndResult.versionValidate(versionCheckResult, desiredVersion))
      .then(() => Promise.resolve(true))
      .catch(() => Promise.reject(
                        new Error('Version not installed of ' + objectName)));
  }
  return execAndCheck(commandAndResult.versionCheck,
                      commandAndResult.checkStdErr,
                      desiredVersion,
                      commandAndResult.versionValidate);
}
function checkVersion ( objectName , versionNumber ) { const desiredVersion = versionNumber ? versionNumber : versions [ objectName ] ; const commandAndResult = commandsAndResults [ objectName ] ; if ( ! commandAndResult ) { return Promise . reject ( new Error ( 'Unrecognized objectName in commandsAndResults' ) ) ; } if ( ! desiredVersion ) { return Promise . reject ( new Error ( 'Unrecognized objectName in versions' ) ) ; } if ( commandAndResult . platform && ! commandAndResult . platform . includes ( os . platform ( ) ) ) { return Promise . reject ( new Error ( 'Requested object is not supported on ' + 'this platform' ) ) ; } if ( typeof commandAndResult . versionCheck === 'function' ) { return promiseTry ( commandAndResult . versionCheck ) . catch ( ( ) => Promise . reject ( new Error ( 'Version Check failed on ' + objectName ) ) ) . then ( ( versionCheckResult ) => commandAndResult . versionValidate ( versionCheckResult , desiredVersion ) ) . then ( ( ) => Promise . resolve ( true ) ) . catch ( ( ) => Promise . reject ( new Error ( 'Version not installed of ' + objectName ) ) ) ; } return execAndCheck ( commandAndResult . versionCheck , commandAndResult . checkStdErr , desiredVersion , commandAndResult . versionValidate ) ; }
Checks if the named object is installed with the named version, if any. If
versionNumber isn't given then we default to checking the versions global
object.
@param {string} objectName Name of the object to validate
@param {string} [versionNumber] An optional string specifying the desired
version. If omitted we will check the versions structure.
@returns {Promise<Error|boolean>} If the desired object is found at the
desired version then a resolve will be returned set to true. Otherwise an
error will be returned specifying what went wrong.
Checks if the named object is installed with the named version if any . If versionNumber isn t given then we default to checking the versions global object .