У меня есть длинная строка, и я хочу заменить server:${address.ip()}:3000
на server:localhost:3000
Вот строка
function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.environment={production:!0,server:"localhost:3000",apikey:"XXXX"}},BRrH:function(t,e,n){t.exports=c;var r=n("bkOT")("simple-peer"),o=n("3oOE"),i=n("P7XM")
Что я делаю, это
update-ip.js
import replace from "replace-in-file";
import * as address from "address";
export class UpdateIpService {
constructor() {
}
static update(filepath: string) {
replace({
files: filepath,
from: /server:\s*[`'"]http?:\/\/.*?[`'"],/g,
to: `server: 'http://${address.ip()}:3000/',`
}).then(changes => {
console.log(`Ip address updated in file: ${changes}`)
}).catch(err => {
console.log('File could not be found to modify')
})
}
}
UpdateIpService.update('./main.js')
Как изменить, пожалуйста, руководство !!!