boot/setup.js
function readSetupToken (cb) {
  var token
  var write = false

  try {
    // try to read setup token from filesystem
    token = keygen.loadSetupToken()
    // if token is blank, try to generate a new token and save it
    if (!token.trim()) {
      write = true
    }
  } catch (err) {
    // if unable to read, try to generate a new token and save it
    write = true
  }

  if (write) {
    try {
      token = keygen.generateSetupToken()
    } catch (err) {
      // if we can't write the token to disk, something is very wrong
      return cb(err)
    }
  }

  // return the token
  cb(null, token)
}
function readSetupToken (cb) {
  var token
  var write = false

  try {
    // try to read setup token from filesystem
    token = keygen.loadSetupToken()
    // if token is blank, try to generate a new token and save it
    if (!token.trim()) {
      write = true
    }
  } catch (err) {
    // if unable to read, try to generate a new token and save it
    write = true
  }

  if (write) {
    try {
      token = keygen.generateSetupToken()
    } catch (err) {
      // if we can't write the token to disk, something is very wrong
      return cb(err)
    }
  }

  // return the token
  cb(null, token)
}
function readSetupToken ( cb ) { var token var write = false try { // try to read setup token from filesystem token = keygen . loadSetupToken ( ) // if token is blank, try to generate a new token and save it if ( ! token . trim ( ) ) { write = true } } catch ( err ) { // if unable to read, try to generate a new token and save it write = true } if ( write ) { try { token = keygen . generateSetupToken ( ) } catch ( err ) { // if we can't write the token to disk, something is very wrong return cb ( err ) } } // return the token cb ( null , token ) }
Read setup token from filesystem or create if missing
Read setup token from filesystem or create if missing