Skip to content

Commit

Permalink
fix(create-turbo): support node 14 (vercel#2638)
Browse files Browse the repository at this point in the history
  • Loading branch information
tknickman authored Nov 8, 2022
1 parent 2f12e3d commit ef9cf2b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions packages/create-turbo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"chalk": "2.4.2",
"execa": "5.1.1",
"fs-extra": "^10.1.0",
"gradient-string": "^2.0.0",
"inquirer": "^8.0.0",
"meow": "^7.1.1",
Expand All @@ -34,6 +35,7 @@
},
"devDependencies": {
"@types/chalk-animation": "^1.6.0",
"@types/fs-extra": "^9.0.13",
"@types/gradient-string": "^1.1.2",
"@types/inquirer": "^7.3.1",
"@types/jest": "^27.4.0",
Expand Down
21 changes: 12 additions & 9 deletions packages/create-turbo/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as path from "path";
import execa from "execa";
import fs from "fs";
import fse from "fs-extra";
import inquirer from "inquirer";
import ora from "ora";
import meow from "meow";
Expand Down Expand Up @@ -136,19 +136,22 @@ async function run() {
let relativeProjectDir = path.relative(process.cwd(), projectDir);
let projectDirIsCurrentDir = relativeProjectDir === "";
if (!projectDirIsCurrentDir) {
if (fs.existsSync(projectDir) && fs.readdirSync(projectDir).length !== 0) {
if (
fse.existsSync(projectDir) &&
fse.readdirSync(projectDir).length !== 0
) {
console.log(
`️🚨 Oops, "${relativeProjectDir}" already exists. Please try again with a different directory.`
);
process.exit(1);
} else {
fs.mkdirSync(projectDir, { recursive: true });
fse.mkdirSync(projectDir, { recursive: true });
}
}

// copy the shared template
let sharedTemplate = path.resolve(__dirname, "../templates", `_shared_ts`);
fs.cpSync(sharedTemplate, projectDir, { recursive: true });
fse.copySync(sharedTemplate, projectDir, { recursive: true });

let packageManagerVersion = getPackageManagerVersion(answers.packageManager);
let packageManagerConfigs = PACKAGE_MANAGERS[answers.packageManager];
Expand All @@ -166,15 +169,15 @@ async function run() {
"../templates",
packageManager.template
);
if (fs.existsSync(packageManagerTemplate)) {
fs.cpSync(packageManagerTemplate, projectDir, {
if (fse.existsSync(packageManagerTemplate)) {
fse.copySync(packageManagerTemplate, projectDir, {
recursive: true,
force: true,
overwrite: true,
});
}

// rename dotfiles
fs.renameSync(
fse.renameSync(
path.join(projectDir, "gitignore"),
path.join(projectDir, ".gitignore")
);
Expand All @@ -196,7 +199,7 @@ async function run() {
sharedPkg.name = projectName;

// write package.json
fs.writeFileSync(
fse.writeFileSync(
path.join(projectDir, "package.json"),
JSON.stringify(sharedPkg, null, 2)
);
Expand Down
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef9cf2b

Please sign in to comment.