generated from markthree/deno-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
11 changed files
with
130 additions
and
790 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { cacheDirs } from "./constant.ts" | ||
import { | ||
brightGreen, | ||
emptyDir, | ||
exists, | ||
gray, | ||
isAbsolute, | ||
resolve, | ||
slash, | ||
} from "./deps.ts" | ||
import { usePm } from "./pm.ts" | ||
|
||
export function logClean(dir: string) { | ||
console.log( | ||
`${brightGreen("√ clean")} ${gray(slash(dir))}`, | ||
) | ||
} | ||
|
||
export async function cleanDirs(dirs = cacheDirs, root = Deno.cwd()) { | ||
const newDirs = dirs.filter(Boolean).map((dir) => { | ||
if (isAbsolute(dir!)) { | ||
return dir | ||
} | ||
return resolve(root, dir!) | ||
}) as string[] | ||
await Promise.all(newDirs.map(async (dir) => { | ||
if (await exists(dir)) { | ||
await emptyDir(dir) | ||
logClean(dir) | ||
} | ||
})) | ||
} | ||
|
||
export async function cleanWorkspaces(dirs: string[] = cacheDirs) { | ||
const pm = usePm() | ||
await Promise.all( | ||
pm.workspaces.map((workspace) => cleanDirs(dirs, workspace)), | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export { | ||
brightGreen, | ||
brightYellow, | ||
dim, | ||
gray, | ||
red, | ||
yellow, | ||
} from "https://deno.land/std@0.218.2/fmt/colors.ts" | ||
export { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts" | ||
export { EnumType } from "https://deno.land/x/cliffy@v1.0.0-rc.3/command/types/enum.ts" | ||
export { default as paramCase } from "https://deno.land/x/case@2.2.0/paramCase.ts" | ||
|
||
export { | ||
emptyDir, | ||
ensureFile, | ||
exists, | ||
expandGlob, | ||
} from "https://deno.land/std@0.218.2/fs/mod.ts" | ||
export { | ||
createUpBases, | ||
slash, | ||
} from "https://deno.land/x/easy_std@v0.7.0/src/path.ts" | ||
|
||
export { parse } from "https://deno.land/std@0.218.2/yaml/parse.ts" | ||
export { createContext } from "npm:unctx@2.3.1" | ||
|
||
export { runtime } from "npm:std-env@3.7.0" | ||
export { execa as denoExeca } from "https://deno.land/x/easy_std@v0.7.0/src/process.ts" | ||
export { | ||
isAbsolute, | ||
isGlob, | ||
join, | ||
relative, | ||
resolve, | ||
} from "https://deno.land/std@0.218.2/path/mod.ts" |
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,31 @@ | ||
import { createUpBases, exists, join, resolve, slash } from "./deps.ts" | ||
|
||
export function existsFile(path: string) { | ||
return exists(path, { | ||
isFile: true, | ||
isDirectory: false, | ||
}) | ||
} | ||
|
||
export async function findUp(files: string[], root = Deno.cwd()) { | ||
const upPaths = createUpBases(root) | ||
for (const upPath of upPaths) { | ||
for (const file of files) { | ||
const path = join(upPath, file) | ||
if (await exists(path)) { | ||
return slash(path) | ||
} | ||
} | ||
} | ||
return null | ||
} | ||
|
||
export async function find(files: string[], root = Deno.cwd()) { | ||
for (const file of files) { | ||
const resolvedFile = resolve(root, file) | ||
if (await existsFile(file)) { | ||
return resolvedFile | ||
} | ||
} | ||
return null | ||
} |
This file was deleted.
Oops, something went wrong.
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