This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
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
1 parent
bf094f1
commit 88641b5
Showing
1 changed file
with
31 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { GluegunToolbox } from "gluegun" | ||
import { simpleGit } from 'simple-git' | ||
|
||
module.exports = { | ||
name: 'create', | ||
run: async (toolbox: GluegunToolbox) => { | ||
const { filesystem, prompt } = toolbox | ||
|
||
const name = await prompt.ask({ | ||
type: 'input', | ||
name: 'name', | ||
message: 'What do you want to name this project?', | ||
}).then((answers) => answers.name) | ||
|
||
// Ensure the folder doesn't already exist | ||
if (filesystem.exists(name)) { | ||
return toolbox.print.error(`Folder ${name} already exists`) | ||
} | ||
|
||
// validate the name to ensure it's npm compatible | ||
if (!/^[a-z0-9-@]+$/.test(name)) { | ||
return toolbox.print.error('Invalid folder name. Use @, lowercase, and dashes only.') | ||
} | ||
await simpleGit({ | ||
baseDir: process.cwd(), | ||
binary: 'git', | ||
maxConcurrentProcesses: 6, | ||
}).clone('git@github.com:hdresearch/create.git', name) | ||
filesystem.remove(`${name}/.git`) | ||
}, | ||
} |