mirror of
https://gitee.com/antv/g6.git
synced 2024-12-06 05:38:47 +08:00
45750f7790
* refactor(site): adjust script * feat(site): add script that can sort docs in specific folder * docs: remove apis folder * docs: add getting-started for chinese version * docs: add core-concept for chinese version * docs: add upgrade for chinese version * docs: remove quick-start * refactor(site): add createGraph global utils * docs: add extension in core concept
42 lines
975 B
TypeScript
42 lines
975 B
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
/**
|
|
* <zh/> 清理自动生成的文档
|
|
*
|
|
* <en/> Clear the auto-generated documents
|
|
*/
|
|
function clear() {
|
|
const baseDir = path.resolve(__dirname, '../docs/api');
|
|
|
|
// read gitignore
|
|
const gitignore = fs.readFileSync(path.resolve(baseDir, '.gitignore'), 'utf-8');
|
|
|
|
// clear all files list in .gitignore
|
|
const lines = gitignore.split('\n');
|
|
|
|
lines.forEach((line) => {
|
|
if (line.startsWith('#')) return;
|
|
|
|
const file = line.trim();
|
|
if (file) {
|
|
const filepath = path.resolve(baseDir, file);
|
|
|
|
if (fs.existsSync(filepath)) {
|
|
if (fs.lstatSync(filepath).isDirectory()) {
|
|
console.log('Clearing folder: ', filepath);
|
|
fs.rmdirSync(filepath, { recursive: true });
|
|
} else {
|
|
console.log('Clearing file: ', filepath);
|
|
fs.unlinkSync(filepath);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// remove .gitignore
|
|
fs.unlinkSync('docs/api/.gitignore');
|
|
}
|
|
|
|
clear();
|