nl_tokens: Returns updated index module requiring and exporting the newly created environment .
pl_tokens: function getModifiedConfigModuleIndex ( fileStr , snakedEnv , classedEnv ) { // TODO [sthzg] we might want to rewrite the AST-mods in this function using a walker. const moduleFileAst = acorn . parse ( fileStr , { module : true } ) ; // if required env was already created, just return the original string if ( jp . paths ( moduleFileAst , ` ${ classedEnv } ` ) . length > 0 ) { return fileStr ; } // insert require call for the new env const envImportAst = acorn . parse ( ` ${ snakedEnv } ${ classedEnv } ` ) ; const insertAt = jp . paths ( moduleFileAst , '$..[?(@.name=="require")]' ) . pop ( ) [ 2 ] + 1 ; moduleFileAst . body . splice ( insertAt , 0 , envImportAst ) ; // add new env to module.exports const exportsAt = jp . paths ( moduleFileAst , '$..[?(@.name=="exports")]' ) . pop ( ) [ 2 ] ; moduleFileAst . body [ exportsAt ] . expression . right . properties . push ( createExportNode ( snakedEnv ) ) ; return escodegen . generate ( moduleFileAst , { <mask> : { indent : { style : '  ' } } } ) ; }