update
This commit is contained in:
parent
422157f96e
commit
205de122a3
@ -1,7 +1,7 @@
|
||||
import glob from 'fast-glob';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import * as path from 'node:path';
|
||||
|
||||
import { Command } from 'commander';
|
||||
export interface FileInfo {
|
||||
name: string;
|
||||
path: string;
|
||||
@ -45,4 +45,15 @@ export const saveJsonToFile = async (dir: string, outputPath: string = 'data.jso
|
||||
}
|
||||
};
|
||||
|
||||
saveJsonToFile('.')
|
||||
const program = new Command();
|
||||
program
|
||||
.description('保存JSON数据')
|
||||
.option('-d, --dir <dir>', '指定目录')
|
||||
.option('-o, --output <output>', '指定输出文件名')
|
||||
.action((opts) => {
|
||||
const dir = opts.dir || '.';
|
||||
const outputPath = opts.output || 'data.json';
|
||||
saveJsonToFile(dir, outputPath);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
@ -19,6 +19,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.0.14",
|
||||
"commander": "^14.0.0",
|
||||
"fast-glob": "^3.3.3"
|
||||
}
|
||||
}
|
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -11,6 +11,9 @@ importers:
|
||||
'@types/node':
|
||||
specifier: ^24.0.14
|
||||
version: 24.0.14
|
||||
commander:
|
||||
specifier: ^14.0.0
|
||||
version: 14.0.0
|
||||
fast-glob:
|
||||
specifier: ^3.3.3
|
||||
version: 3.3.3
|
||||
@ -38,6 +41,10 @@ packages:
|
||||
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
commander@14.0.0:
|
||||
resolution: {integrity: sha512-2uM9rYjPvyq39NwLRqaiLtWHyDC1FvryJDa2ATTVims5YAS4PupsEQsDvP14FqhFr0P49CYDugi59xaxJlTXRA==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
fast-glob@3.3.3:
|
||||
resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==}
|
||||
engines: {node: '>=8.6.0'}
|
||||
@ -116,6 +123,8 @@ snapshots:
|
||||
dependencies:
|
||||
fill-range: 7.1.1
|
||||
|
||||
commander@14.0.0: {}
|
||||
|
||||
fast-glob@3.3.3:
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user