Skip to content

Commit

Permalink
ask about running setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 18, 2022
1 parent 0357494 commit 80f3d9e
Show file tree
Hide file tree
Showing 3 changed files with 923 additions and 5 deletions.
37 changes: 32 additions & 5 deletions remix.init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { execSync } = require("child_process");
const crypto = require("crypto");
const fs = require("fs/promises");
const path = require("path");
const inquirer = require("inquirer");

const toml = require("@iarna/toml");
const sort = require("sort-package-json");
Expand Down Expand Up @@ -62,12 +63,38 @@ async function main({ rootDirectory }) {
fs.writeFile(PACKAGE_JSON_PATH, newPackageJson),
]);

console.log(
`Running the setup script to make sure everything was set up properly`
);
execSync(`npm run setup`, { stdio: "inherit", cwd: rootDirectory });
await setup({ rootDirectory });
}

async function setup({ rootDirectory }) {
const answers = await inquirer
.prompt([
{
name: "setup",
type: "confirm",
default: false,
message:
"Do you want to run the build/tests/etc to verify things are setup properly?",
},
])
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
} else {
throw error;
}
});

if (answers.setup) {
console.log(
`Running the setup script to make sure everything was set up properly`
);
execSync(`npm run setup`, { stdio: "inherit", cwd: rootDirectory });

console.log(`✅ Project is ready! Start development with "npm run dev"`);
console.log(`✅ Project is ready! Start development with "npm run dev"`);
} else {
console.log(`✅ Sounds good. Check the README.md for setup instructions.`);
}
}

module.exports = main;
Loading

0 comments on commit 80f3d9e

Please sign in to comment.