This repository was archived by the owner on Dec 17, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " create-djs-app" ,
3- "version" : " 1.1.2-dev.4 " ,
3+ "version" : " 1.1.2-dev.5 " ,
44 "description" : " Create a Discord.js project easily." ,
55 "main" : " index.js" ,
66 "bin" : {
Original file line number Diff line number Diff line change 88 promptGit ,
99 promptGuildId ,
1010 promptInstall ,
11+ promptLocation ,
1112 promptName ,
1213 promptTemplate ,
1314 promptToken ,
@@ -43,6 +44,7 @@ export function argsToOptions(rawArgs) {
4344
4445export async function prompt ( options ) {
4546 const name = await promptName ( ) ;
47+ const location = await promptLocation ( ) ;
4648 const token = await promptToken ( ) ;
4749 const guildId = await promptGuildId ( ) ;
4850
@@ -68,6 +70,7 @@ export async function prompt(options) {
6870 name : name ,
6971 token : token ,
7072 guildId : guildId ,
73+ targetDirectory : location ,
7174 template : options . template || template ,
7275 git : options . git || git ,
7376 runInstall : options . runInstall || runInstall ,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ async function copyTemplateFiles(options) {
4444export async function createProject ( options ) {
4545 options = {
4646 ...options ,
47- targetDirectory : options . targetDirectory || process . cwd ( ) ,
47+ targetDirectory : options . targetDirectory || "." ,
4848 } ;
4949
5050 const templateDir = path . resolve (
@@ -74,6 +74,7 @@ export async function createProject(options) {
7474 {
7575 title : `Install dependencies using ${ getPkgManager ( ) } ` ,
7676 task : ( ) => installPkgs ( options ) ,
77+ enabled : ( ) => options . runInstall ,
7778 } ,
7879 ] ) ;
7980
Original file line number Diff line number Diff line change 11import inquirer from "inquirer" ;
22import { getPkgManager , validateNpmName } from "../functions" ;
33import path from "path" ;
4+ import { existsSync } from "fs" ;
45
56export async function promptName ( ) {
67 const { name } = await inquirer . prompt ( {
@@ -20,6 +21,24 @@ export async function promptName() {
2021 return name ;
2122}
2223
24+ export async function promptLocation ( ) {
25+ const { dir } = await inquirer . prompt ( {
26+ type : "input" ,
27+ name : "dir" ,
28+ message : "Where would you like to create your project?" ,
29+ default : "." ,
30+ validate : ( dir ) => {
31+ if ( dir === "." ) return true ;
32+
33+ const validation = existsSync ( dir ) ;
34+ if ( ! validation ) return true ;
35+ return "That directory already exists." ;
36+ } ,
37+ } ) ;
38+
39+ return dir ;
40+ }
41+
2342export async function promptToken ( ) {
2443 const { confirmToken } = await inquirer . prompt ( {
2544 type : "confirm" ,
You can’t perform that action at this time.
0 commit comments