-
-
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
99 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
import { exists } from "@std/fs"; | ||
import { parse } from "@std/jsonc"; | ||
|
||
export async function findConfig() { | ||
if (await exists("deno.json")) { | ||
if (await exists("deno.json") && await hasImports("deno.json")) { | ||
return "deno.json"; | ||
} else if (await exists("deno.jsonc")) { | ||
} | ||
if (await exists("deno.jsonc") && await hasImports("deno.jsonc")) { | ||
return "deno.jsonc"; | ||
} | ||
} | ||
|
||
async function hasImports(config: string): Promise<boolean> { | ||
if (!config) return false; | ||
const jsonc = parse(await Deno.readTextFile(config)); | ||
return jsonc !== null && typeof jsonc === "object" && "imports" in jsonc; | ||
} | ||
|
||
export async function findLock() { | ||
if (await exists("deno.lock")) { | ||
return "deno.lock"; | ||
} | ||
} | ||
|
||
export async function findSource() { | ||
const source: string[] = []; | ||
for await (const entry of Deno.readDir(".")) { | ||
if (entry.isFile && entry.name.endsWith(".ts")) { | ||
source.push(entry.name); | ||
} | ||
} | ||
return source; | ||
}; |
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