-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
a69905a
commit 0dbee32
Showing
5 changed files
with
63 additions
and
9 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,30 @@ | ||
import { copy } from "fs-extra"; | ||
import { isAbsolute, join, parse, relative } from "node:path"; | ||
import { cwd as processCwd } from "node:process"; | ||
import { getDocumentsPath } from "./helpers.js"; | ||
import { success } from "./logging.js"; | ||
|
||
export async function eject({ | ||
cwd = processCwd(), | ||
path = "", | ||
}: { cwd?: string; path?: string } = {}) { | ||
const destination = getDestinationPath(cwd, path); | ||
|
||
await copy(getDocumentsPath(), destination, { | ||
filter: (src) => parse(src).base !== "config.ts", | ||
}); | ||
|
||
success(`Ejected all documents at \`${relative(cwd, destination)}\`.`); | ||
} | ||
|
||
function getDestinationPath(cwd: string, path: string): string { | ||
if (path) { | ||
if (isAbsolute(path)) { | ||
return path; | ||
} else { | ||
return join(cwd, path); | ||
} | ||
} | ||
|
||
return join(cwd, ".gember"); | ||
} |
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,6 @@ | ||
import { dirname, join } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
export function getDocumentsPath(): string { | ||
return join(dirname(fileURLToPath(import.meta.url)), "../documents"); | ||
} |
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,5 @@ | ||
import chalk from "chalk"; | ||
|
||
export function success(message: string): void { | ||
console.log(chalk.green(`🫚 ${message}`)); | ||
} |