forked from huge/frontEnd/hugeOA

Mr Ke
2020-04-06 562ece16c022e154197e01170e9d0363ec0b9859
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require('dotenv').config();
 
const {
  REACT_APP_CODER = '`.env.local#REACT_APP_CODER`',
  REACT_APP_EMAIL = '`.env.local#REACT_APP_EMAIL`',
} = process.env;
 
exports.headers = () => [
  '/* eslint-disable */',
  `/**${REACT_APP_CODER}`,
  ` * ${new Date().toLocaleString('en-US', { timeZone: 'Asia/Shanghai' })}`,
  ` * doc comment for the file goes here`,
  ` */`,
  ``,
  `/** Happy Coding */`,
];
 
exports.comment = file => {
  const fs = require('fs');
  const text = fs.readFileSync(file, {
    encoding: 'utf-8',
  });
 
  function reduce(text, data) {
    const match = /^\/{3} *(.+)$/im.exec(text);
    if (!match) return data;
    data.push(`// ${match[1]}`);
    return reduce(text.slice(match.index + match[0].length), data);
  }
 
  return reduce(text, []);
};