-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,14 @@ | ||
import * as osPath from "path"; | ||
import * as yaml from "js-yaml"; | ||
|
||
export type StackQuery = { | ||
compiler: Compiler; | ||
locals: Locals; | ||
}; | ||
|
||
export type Compiler = { | ||
actual: string; | ||
wanted: string; | ||
}; | ||
|
||
export type Locals = { [key: string]: Local }; | ||
|
||
export type Local = { | ||
path: string; | ||
version: string; | ||
}; | ||
|
||
export function parseStackQuery(stdout: string): StackQuery { | ||
return yaml.load(stdout) as StackQuery; | ||
} | ||
|
||
export function getLocalStackWorks( | ||
stackQuery: StackQuery, | ||
stackWorks: string[] = [], | ||
): string[] { | ||
for (const k in stackQuery.locals) { | ||
const { path } = stackQuery.locals[k]; | ||
const stackWork = osPath.join(path, ".stack-work"); | ||
|
||
if (!stackWorks.includes(stackWork)) { | ||
stackWorks.push(stackWork); | ||
} | ||
} | ||
|
||
return stackWorks; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as fs from "fs"; | ||
import { join as joinPath } from "path"; | ||
import * as yaml from "js-yaml"; | ||
|
||
export type StackYaml = { | ||
resolver: string; | ||
packages: string[] | null; | ||
}; | ||
|
||
export function readStackYamlSync(path: string): StackYaml { | ||
const contents = fs.readFileSync(path, { encoding: "utf-8" }); | ||
return yaml.load(contents) as StackYaml; | ||
} | ||
|
||
export function packagesStackWorks(stackYaml: StackYaml): string[] { | ||
const cwd = process.cwd(); | ||
|
||
return [".stack-work"] | ||
.concat((stackYaml.packages ?? []).map((p) => joinPath(p, ".stack-work"))) | ||
.map((sw) => joinPath(cwd, sw)); | ||
} |