vendor: amis 6.13.0 base (fork root)
This commit is contained in:
33
packages/office-viewer/tools/convertFileToBase64.ts
Normal file
33
packages/office-viewer/tools/convertFileToBase64.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 将文件转成 base64 字符串
|
||||
*/
|
||||
import {readFileSync, writeFileSync} from 'fs';
|
||||
|
||||
import prettier from 'prettier';
|
||||
|
||||
import process from 'node:process';
|
||||
import path from 'node:path';
|
||||
|
||||
const file = process.argv[2];
|
||||
|
||||
const tsFile = process.argv[3];
|
||||
|
||||
const content = readFileSync(file);
|
||||
|
||||
const varName = path.basename(tsFile.replace(/\.ts$/, ''));
|
||||
|
||||
const base64Content = content.toString('base64');
|
||||
|
||||
const outputFile = `
|
||||
/** generated by convertFileToBase64.ts, do not edit */
|
||||
|
||||
export const ${varName} = '${base64Content}';
|
||||
`;
|
||||
|
||||
prettier.resolveConfig('../../../.prettierrc').then(options => {
|
||||
const formatted = prettier.format(outputFile, {
|
||||
...options,
|
||||
parser: 'typescript'
|
||||
});
|
||||
writeFileSync(tsFile, formatted);
|
||||
});
|
||||
Reference in New Issue
Block a user