-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
9360359
commit 8046c40
Showing
6 changed files
with
275 additions
and
164 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { mkdir, writeJson, copy, exists } from "fs-extra"; | ||
import path from "path"; | ||
import { $ } from "execa"; | ||
import { version } from "../package.json"; | ||
|
||
export async function createProject(name: string) { | ||
await mkdir(name); | ||
await writeJson(path.join(name, "package.json"), { | ||
name: `${name}-fetchbook`, | ||
version: "1.0.0", | ||
description: `${name}'s fetchbook`, | ||
scripts: { | ||
test: "fetchbook run --all", | ||
}, | ||
}); | ||
await initProject(name); | ||
await $`prettier --write ${name}`; | ||
} | ||
|
||
export async function initProject(cwd = ".") { | ||
if (!(await exists(path.join(cwd, "package.json")))) { | ||
throw "You must run init inside the root of a node project"; | ||
} | ||
await $`add-dependencies ${path.join( | ||
cwd, | ||
"package.json", | ||
)} --dev fetchbook@^${version}`; | ||
await copy( | ||
path.join(__dirname, "..", "examples"), | ||
path.join(cwd, "fetchbook"), | ||
); | ||
} |
Oops, something went wrong.