programatically add a function to a javascript file from another javascript -
i want add function/code java script file script. have below code in a.js
/*some comments.. 4-5 lines*/ module.exports = { aaa: aaa, add: add }; var asd = 'test'; function aaa() { console.log('ddddd --- ' + asd); } function add(a, b) { var sum = + b; console.log(sum); } from js file need add below function a.js , update module.exports list
function diff(c, d) { ///some code } i parsed contents of a.js , new function esprima parser , splice function added code. converted ast code recast , wrote file comments gone.
how insert code without affecting other content of original file?
Comments
Post a Comment