// initEvironment prepares the javascript vm and compiles the transformer script
initEvironment prepares the javascript vm and compiles the transformer script
// initEvironment prepares the javascript vm and compiles the transformer script
func (t *Transformer) initEnvironment() (err error) {
	t.vm = otto.New()
	if _, err = t.vm.Run(`module = {}`); err != nil {
		return t.transformerError(adaptor.CRITICAL, err, nil)
	}
	if t.script, err = t.vm.Compile("", t.fn); err != nil {
		return t.transformerError(adaptor.CRITICAL, err, nil)
	}
	_, err = t.vm.Run(t.script)
	if err != nil {
		return t.transformerError(adaptor.CRITICAL, err, nil)
	}
	return
}
func ( t * Transformer ) initEnvironment ( ) ( err error ) { t . vm = otto . New ( ) if _ , err = t . vm . Run ( `module = {}` ) ; err != nil { return t . transformerError ( adaptor . CRITICAL , err , nil ) } if t . script , err = t . vm . Compile ( " " , t . fn ) ; err != nil { return t . transformerError ( adaptor . CRITICAL , err , nil ) } _ , err = t . vm . Run ( t . script ) if err != nil { return t . transformerError ( adaptor . CRITICAL , err , nil ) } return }
initEvironment prepares the javascript vm and compiles the transformer script
initEvironment prepares the javascript vm and compiles the transformer script
// set up the vm environment, make `module = {}` // compile our script // run the script, ignore the output