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
|
p
|
||||||
.command("sync")
|
.command("sync")
|
||||||
.action(() => {
|
.action(() => {
|
||||||
const getMixFiles = (): { name: string, content: MixFile}[] => {
|
const mixDir = isDev
|
||||||
const files = readdirSync(isDev ? process.cwd() : homedir(), { withFileTypes: true })
|
? process.cwd()
|
||||||
.filter((dirent) => dirent.isFile() && dirent.name.endsWith("mix.hjson") && !dirent.name.startsWith("_"))
|
: path.join(homedir(), ".mix");
|
||||||
.map((dirent) => ({
|
|
||||||
name: dirent.name,
|
|
||||||
content: h.parse(readFileSync(dirent.name, "utf-8"))
|
|
||||||
}));
|
|
||||||
|
|
||||||
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 mergeMixFiles = (files: MixFile[]): MixFile => {
|
||||||
const merged: MixFile = {};
|
const merged: MixFile = {};
|
||||||
|
@ -50,9 +52,10 @@ export const registerSyncCommand = (p: Command) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getLockFile = (): MixLockFile => {
|
const getLockFile = (): MixLockFile => {
|
||||||
const mixDir = isDev ? "" : path.join(homedir(), ".mix");
|
return h.parse(
|
||||||
return h.parse(readFileSync(path.join(mixDir, "mix.lock"), "utf-8"));
|
readFileSync(path.join(mixDir, "mix.lock"), "utf-8")
|
||||||
}
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const diff = (file: MixFile, lock: MixLockFile) => {
|
const diff = (file: MixFile, lock: MixLockFile) => {
|
||||||
const toInstall: MixPackage[] = [];
|
const toInstall: MixPackage[] = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue