initWorkPath.js 564 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. const fs = require('fs')
  7. const path = require('path')
  8. const version = require('../version')
  9. module.exports = (work_path, sys_hosts_path) => {
  10. fs.mkdirSync(work_path)
  11. let cnt = fs.readFileSync(sys_hosts_path, 'utf-8')
  12. let fn_data = path.join(work_path, 'data.json')
  13. let data = {
  14. list: [{
  15. title: 'My hosts',
  16. content: '# My hosts'
  17. }, {
  18. title: 'backup',
  19. content: cnt
  20. }],
  21. version: version
  22. }
  23. fs.writeFileSync(fn_data, JSON.stringify(data), 'utf-8')
  24. }