a
This commit is contained in:
parent
07e50ddc1e
commit
ddc0138077
1 changed files with 15 additions and 12 deletions
27
cmd/sync.ts
27
cmd/sync.ts
|
@ -11,16 +11,18 @@ export const registerSyncCommand = (p: Command) => {
|
|||
p
|
||||
.command("sync")
|
||||
.action(() => {
|
||||
const getMixFiles = (): { name: string, content: MixFile}[] => {
|
||||
const files = readdirSync(isDev ? process.cwd() : homedir(), { withFileTypes: true })
|
||||
.filter((dirent) => dirent.isFile() && dirent.name.endsWith("mix.hjson") && !dirent.name.startsWith("_"))
|
||||
.map((dirent) => ({
|
||||
name: dirent.name,
|
||||
content: h.parse(readFileSync(dirent.name, "utf-8"))
|
||||
}));
|
||||
const mixDir = isDev
|
||||
? process.cwd()
|
||||
: path.join(homedir(), ".mix");
|
||||
|
||||
return files
|
||||
}
|
||||
const getMixFiles = (): { name: string, content: MixFile }[] => {
|
||||
return readdirSync(mixDir, { withFileTypes: true })
|
||||
.filter(d => d.isFile() && d.name.endsWith("mix.hjson") && !d.name.startsWith("_"))
|
||||
.map(d => ({
|
||||
name: d.name,
|
||||
content: h.parse(readFileSync(path.join(mixDir, d.name), "utf-8"))
|
||||
}));
|
||||
};
|
||||
|
||||
const mergeMixFiles = (files: MixFile[]): MixFile => {
|
||||
const merged: MixFile = {};
|
||||
|
@ -50,9 +52,10 @@ export const registerSyncCommand = (p: Command) => {
|
|||
}
|
||||
|
||||
const getLockFile = (): MixLockFile => {
|
||||
const mixDir = isDev ? "" : path.join(homedir(), ".mix");
|
||||
return h.parse(readFileSync(path.join(mixDir, "mix.lock"), "utf-8"));
|
||||
}
|
||||
return h.parse(
|
||||
readFileSync(path.join(mixDir, "mix.lock"), "utf-8")
|
||||
);
|
||||
};
|
||||
|
||||
const diff = (file: MixFile, lock: MixLockFile) => {
|
||||
const toInstall: MixPackage[] = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue