src/File.js
function(options) {
  options = options || {};

  this.path = PATH.resolve(PATH.normalize(options.path));
  this.exists = FS.existsSync(this.path);
  this.umask = 'umask' in options ? options.umask : File.UMASK;

  if (this.exists) {
    this.stats = this.getStats();
    this.type = this.getType();
    this.mode = this.stats.mode & 511; // 511 == 0777
    this.uid = this.stats.uid;
    this.gid = this.stats.gid;
  }
  else {
    this.owner = options.owner;
    this.group = options.group;

    if ('exists' in options && options.exists) {
      throw new File.FileMissingException('File was expected to exist, but does not.');
    }

    if ('type' in options) {
      if (options.type in File.Types) {
        this.type = File.Types[options.type];
      }
      else {
        throw new File.UnknownFileTypeException('Unknown file type: ' + options.type + '.');
      }
    }
    else {
      throw new File.MissingRequiredParameterException('"type" is required for nonexistent files.');
    }

    switch (this.type) {
    case File.Types.file:
      this.content = 'content' in options ? options.content : '';

      break;
    case File.Types.symlink:
      if ('dest' in options) {
        this.dest = options.dest;
      }
      else {
        throw new File.MissingRequiredParameterException('"dest" is a required option for symlink files.');
      }

      break;
    }

    this.mode = File.interpretMode(options.mode, options.type, this.umask);
  }
}
function(options) {
  options = options || {};

  this.path = PATH.resolve(PATH.normalize(options.path));
  this.exists = FS.existsSync(this.path);
  this.umask = 'umask' in options ? options.umask : File.UMASK;

  if (this.exists) {
    this.stats = this.getStats();
    this.type = this.getType();
    this.mode = this.stats.mode & 511; // 511 == 0777
    this.uid = this.stats.uid;
    this.gid = this.stats.gid;
  }
  else {
    this.owner = options.owner;
    this.group = options.group;

    if ('exists' in options && options.exists) {
      throw new File.FileMissingException('File was expected to exist, but does not.');
    }

    if ('type' in options) {
      if (options.type in File.Types) {
        this.type = File.Types[options.type];
      }
      else {
        throw new File.UnknownFileTypeException('Unknown file type: ' + options.type + '.');
      }
    }
    else {
      throw new File.MissingRequiredParameterException('"type" is required for nonexistent files.');
    }

    switch (this.type) {
    case File.Types.file:
      this.content = 'content' in options ? options.content : '';

      break;
    case File.Types.symlink:
      if ('dest' in options) {
        this.dest = options.dest;
      }
      else {
        throw new File.MissingRequiredParameterException('"dest" is a required option for symlink files.');
      }

      break;
    }

    this.mode = File.interpretMode(options.mode, options.type, this.umask);
  }
}
function ( options ) { options = options || { } ; this . path = PATH . resolve ( PATH . normalize ( options . path ) ) ; this . exists = FS . existsSync ( this . path ) ; this . umask = 'umask' in options ? options . umask : File . UMASK ; if ( this . exists ) { this . stats = this . getStats ( ) ; this . type = this . getType ( ) ; this . mode = this . stats . mode & 511 ; // 511 == 0777 this . uid = this . stats . uid ; this . gid = this . stats . gid ; } else { this . owner = options . owner ; this . group = options . group ; if ( 'exists' in options && options . exists ) { throw new File . FileMissingException ( 'File was expected to exist, but does not.' ) ; } if ( 'type' in options ) { if ( options . type in File . Types ) { this . type = File . Types [ options . type ] ; } else { throw new File . UnknownFileTypeException ( 'Unknown file type: ' + options . type + '.' ) ; } } else { throw new File . MissingRequiredParameterException ( '"type" is required for nonexistent files.' ) ; } switch ( this . type ) { case File . Types . file : this . content = 'content' in options ? options . content : '' ; break ; case File . Types . symlink : if ( 'dest' in options ) { this . dest = options . dest ; } else { throw new File . MissingRequiredParameterException ( '"dest" is a required option for symlink files.' ) ; } break ; } this . mode = File . interpretMode ( options . mode , options . type , this . umask ) ; } }
A File represents any regular, directory, or symlink file.

@param {object} options
A File represents any regular directory or symlink file .