mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
检测行数
This commit is contained in:
parent
57204b11c4
commit
c179f05602
@ -1,6 +1,5 @@
|
|||||||
import fs from 'fs/promises';
|
|
||||||
import fss from 'fs';
|
import fss from 'fs';
|
||||||
import fse from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import Fontmin from 'fontmin';
|
import Fontmin from 'fontmin';
|
||||||
import * as babel from '@babel/core';
|
import * as babel from '@babel/core';
|
||||||
import * as rollup from 'rollup';
|
import * as rollup from 'rollup';
|
||||||
@ -45,11 +44,11 @@ import commonjs from '@rollup/plugin-commonjs';
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
if (process.argv[2] !== '1') await fse.remove('./dist/maps/');
|
if (process.argv[2] !== '1') await fs.remove('./dist/maps/');
|
||||||
// 在线查看什么都看不到,这编辑器难道还需要留着吗?
|
// 在线查看什么都看不到,这编辑器难道还需要留着吗?
|
||||||
await fse.remove('./dist/_server');
|
await fs.remove('./dist/_server');
|
||||||
await fse.remove('./dist/editor.html');
|
await fs.remove('./dist/editor.html');
|
||||||
await fse.remove('./dist/server.cjs');
|
await fs.remove('./dist/server.cjs');
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
// 2. 压缩字体
|
// 2. 压缩字体
|
||||||
@ -106,19 +105,19 @@ import commonjs from '@rollup/plugin-commonjs';
|
|||||||
]);
|
]);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
...fonts.map(v => {
|
...fonts.map(v => {
|
||||||
return fse.rename(
|
return fs.rename(
|
||||||
`./dist/project/fonts/${v}.ttf`,
|
`./dist/project/fonts/${v}.ttf`,
|
||||||
`./dist/project/fonts/${v}-${timestamp}.ttf`
|
`./dist/project/fonts/${v}-${timestamp}.ttf`
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await fse.copy('./public/project/fonts', './dist/project/fonts');
|
await fs.copy('./public/project/fonts', './dist/project/fonts');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 压缩js插件
|
// 3. 压缩js插件
|
||||||
try {
|
try {
|
||||||
await fse.remove('./dist/project/plugin.min.js');
|
await fs.remove('./dist/project/plugin.min.js');
|
||||||
|
|
||||||
const build = await rollup.rollup({
|
const build = await rollup.rollup({
|
||||||
input: 'src/plugin/game/index.js',
|
input: 'src/plugin/game/index.js',
|
||||||
@ -141,7 +140,7 @@ import commonjs from '@rollup/plugin-commonjs';
|
|||||||
file: './dist/project/plugin.min.js'
|
file: './dist/project/plugin.min.js'
|
||||||
});
|
});
|
||||||
|
|
||||||
await fse.remove('./dist/project/plugin/');
|
await fs.remove('./dist/project/plugin/');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
||||||
@ -169,6 +168,6 @@ import commonjs from '@rollup/plugin-commonjs';
|
|||||||
|
|
||||||
// 5. 杂项
|
// 5. 杂项
|
||||||
try {
|
try {
|
||||||
await fse.copy('./LICENSE', './dist/LICENSE');
|
await fs.copy('./LICENSE', './dist/LICENSE');
|
||||||
} catch {}
|
} catch {}
|
||||||
})();
|
})();
|
||||||
|
31
script/lines.ts
Normal file
31
script/lines.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import fs from 'fs-extra';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
|
(async function () {
|
||||||
|
const dir = './src';
|
||||||
|
let total = 0;
|
||||||
|
|
||||||
|
const check = async (dir: string) => {
|
||||||
|
const d = await fs.readdir(dir);
|
||||||
|
for await (const one of d) {
|
||||||
|
const stat = await fs.stat(resolve(dir, one));
|
||||||
|
if (stat.isFile()) {
|
||||||
|
if (
|
||||||
|
['.ts', '.tsx', '.js', '.jsx', '.vue', '.less'].some(v =>
|
||||||
|
one.endsWith(v)
|
||||||
|
) &&
|
||||||
|
!one.endsWith('.d.ts')
|
||||||
|
) {
|
||||||
|
const file = await fs.readFile(resolve(dir, one), 'utf-8');
|
||||||
|
const lines = file.split('\n').length;
|
||||||
|
total += lines;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await check(resolve(dir, one));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await check(dir);
|
||||||
|
|
||||||
|
console.log(total);
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user