lib/fixture.js
// have to gather up symlinks for the end
have to gather up symlinks for the end
have to gather up symlinks for the end
static make (abs, f, symlinks = null) {
    if (typeof f === 'string' || Buffer.isBuffer(f))
      f = new Fixture('file', f)
    else if (f && typeof f === 'object' && !(f instanceof Fixture))
      f = new Fixture('dir', f)
    else if (!(f instanceof Fixture))
      throw new Error('invalid fixture type: ' + f)
    const isRoot = symlinks === null
    symlinks = symlinks || {}
    switch (f.type) {
      case 'symlink':
        symlinks[abs] = f.content
        break
      case 'link':
        linkSync(resolve(dirname(abs), f.content), abs)
        break
      case 'dir':
        mkdirRecursiveSync(abs)
        for (const [name, fixture] of Object.entries(f.content))
          Fixture.make(`${abs}/${name}`, fixture, symlinks)
        break
      case 'file':
        writeFileSync(abs, f.content)
        break
    }
    if (isRoot) {
      for (const [abs, target] of Object.entries(symlinks)) {
        symlinkSync(target, abs, isDir(abs, target) ? 'junction' : 'file')
      }
    }
  }
static make ( abs , f , symlinks = null ) { if ( typeof f === 'string' || Buffer . isBuffer ( f ) ) f = new Fixture ( 'file' , f ) else if ( f && typeof f === 'object' && ! ( f instanceof Fixture ) ) f = new Fixture ( 'dir' , f ) else if ( ! ( f instanceof Fixture ) ) throw new Error ( 'invalid fixture type: ' + f ) const isRoot = symlinks === null symlinks = symlinks || { } switch ( f . type ) { case 'symlink' : symlinks [ abs ] = f . content break case 'link' : linkSync ( resolve ( dirname ( abs ) , f . content ) , abs ) break case 'dir' : mkdirRecursiveSync ( abs ) for ( const [ name , fixture ] of Object . entries ( f . content ) ) Fixture . make ( ` ${ abs } ${ name } ` , fixture , symlinks ) break case 'file' : writeFileSync ( abs , f . content ) break } if ( isRoot ) { for ( const [ abs , target ] of Object . entries ( symlinks ) ) { symlinkSync ( target , abs , isDir ( abs , target ) ? 'junction' : 'file' ) } } }
have to gather up symlinks for the end
have to gather up symlinks for the end
// have to gather up symlinks for the end, because windows // create all those symlinks we were asked for