Skip to content

Commit d6ea96b

Browse files
committed
Use example name as the dirName
Starters behave the same
1 parent 516d92e commit d6ea96b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ function prompt(question, defaultAnswer) {
2626
});
2727
}
2828

29-
async function installDependencies() {
29+
async function installDependencies(dirName) {
3030
console.log(`Installing dependencies ...`);
3131
await run(`cd ${dirName} && npm install`);
3232
}
3333

34-
async function initGit() {
34+
async function initGit(dirName) {
3535
console.log(`Setting up Git ...`);
3636
await run(`rm -rf ${dirName}/.git`);
3737
await run(
@@ -64,19 +64,20 @@ const starter = config.starters.find(
6464
// Current time in seconds.
6565
const timestamp = Math.round(new Date().getTime() / 1000);
6666

67-
const dirName = args._[0] ?? `${config.defaults.dirName}-${timestamp}`;
68-
6967
/* --- New Project from Starter --- */
7068

7169
async function cloneStarter() {
70+
// Set references
71+
const dirName = args._[0] ?? `${config.defaults.dirName}-${timestamp}`;
72+
7273
// Clone repo
7374
const cloneCommand = `git clone --depth=1 ${starter.repoUrl} ${dirName}`;
7475
console.log(`\nCreating new project in ${dirName} ...`);
7576
await run(cloneCommand);
7677

7778
// Project Setup
78-
await installDependencies();
79-
await initGit();
79+
await installDependencies(dirName);
80+
await initGit(dirName);
8081

8182
// Output next steps:
8283
console.log(`
@@ -91,7 +92,8 @@ Follow the instructions for getting Started here:
9192
/* --- New Project from Example --- */
9293

9394
async function cloneExample() {
94-
const tmpDir = `examples-sparse-${timestamp}`;
95+
const dirName = args._[0] ?? `${args.example}-${timestamp}`;
96+
const tmpDir = `__tmp${timestamp}__`;
9597
console.log(`\nCreating new project in ${dirName} ...`);
9698

9799
try {
@@ -107,8 +109,8 @@ async function cloneExample() {
107109
await run(`rm -rf ${tmpDir}`);
108110

109111
// Project Setup
110-
await installDependencies();
111-
await initGit();
112+
await installDependencies(dirName);
113+
await initGit(dirName);
112114
} catch (err) {
113115
console.error(err);
114116
if (fs.existsSync(dirName)) await run(`rm -rf ${dirName}`);

0 commit comments

Comments
 (0)