// WriteVendorFile writes the current vendor file to the context location.

WriteVendorFile writes the current vendor file to the context location.
// WriteVendorFile writes the current vendor file to the context location .
func (ctx *Context) WriteVendorFile() (err error) {
	perm := ros.FileMode(0666)
	fi, err := os.Stat(ctx.VendorFilePath)
	if err == nil {
		perm = fi.Mode()
	}
	ctx.VendorFile.RootPath = ctx.RootImportPath
	buf := &bytes.Buffer{}
	err = ctx.VendorFile.Marshal(buf)
	if err != nil {
		return
	}
	err = buf.WriteByte('\n')
	if err != nil {
		return
	}
	dir, _ := filepath.Split(ctx.VendorFilePath)
	err = os.MkdirAll(dir, 0777)
	if err != nil {
		return
	}
	for i := range ctx.VendorFile.Package {
		vp := ctx.VendorFile.Package[i]
		vp.Add = false
	}
	err = safefile.WriteFile(ctx.VendorFilePath, buf.Bytes(), perm)
	if err == nil {
		for _, vp := range ctx.VendorFile.Package {
			vp.Add = false
		}
	}
	return
}
func ( ctx * Context ) WriteVendorFile ( ) ( err error ) { perm := ros . FileMode ( 0666 ) fi , err := os . Stat ( ctx . VendorFilePath ) if err == nil { perm = fi . Mode ( ) } ctx . VendorFile . RootPath = ctx . RootImportPath buf := & bytes . Buffer { } err = ctx . VendorFile . Marshal ( buf ) if err != nil { return } err = buf . WriteByte ( '\n' ) if err != nil { return } dir , _ := filepath . Split ( ctx . VendorFilePath ) err = os . MkdirAll ( dir , 0777 ) if err != nil { return } for i := range ctx . VendorFile . Package { vp := ctx . VendorFile . Package [ i ] vp . Add = false } err = safefile . WriteFile ( ctx . VendorFilePath , buf . Bytes ( ) , perm ) if err == nil { for _ , vp := range ctx . VendorFile . Package { vp . Add = false } } return }
WriteVendorFile writes the current vendor file to the context location.
WriteVendorFile writes the current vendor file to the context location .