update-hosts.js // 请用管理员权限运行var request = require('sync-request');var fs = require('fs');var url = 'https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts-files/hosts';var co = request('GET', url).getBody().toString();
// 请用管理员权限运行 var request = require('sync-request'); var fs = require('fs'); var url = 'https://coding.net/u/scaffrey/p/hosts/git/raw/master/hosts-files/hosts'; var co = request('GET', url).getBody().toString(); fs.renameSync(`C:/windows/system32/drivers/etc/hosts`, `C:/windows/system32/drivers/etc/hosts.bak`); fs.writeFileSync(`C:/windows/system32/drivers/etc/hosts`, co); console.log('done..');